;"> </td> </tr> <tr> <td align="center">投票项:</td> <td> <textarea name="votenote" rows="8" id ="votenote" style="width:80%"> <movies> <movie> <title>您想去哪个城市:</title> <id>1</id> <count>350</count> <content>广东</content> </movie> <movie> <title>您想去哪个城市:</title> <id>2</id> <count>47</count> <content>湖南</content> </movie> <movie> <title>您想去哪个城市:</title> <id>3</id> <count>118</count> <content>上海</content> </movie> <movie> <title>您想去哪个城市:</title> <id>4</id> <count>122</count> <content>北京</content> </movie> <movie> <title>您想去哪个城市:</title> <id>5</id> <count>80</count> <content>湖北</content> </movie> </movies></textarea></td> </tr> <tr> <td height="47"> </td> <td><input type="submit" name="Submit" value="保存调查数据"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> </tr> </head> </html>
2、update.php
<?php $con = mysql_connect('localhost','root','root')or die("could not connect database");//此处根据自己的数据库的名字,密码进行修改 mysql_query("set names utf8"); mysql_select_db('cms_vote')or die("could not select database"); $aid = $_POST['aid']; $votename=$_POST['votename']; $starttime=$_POST['starttime']; $endtime=$_POST['endtime']; $votenote=$_POST['votenote']; $totalcount=$_POST['totalcount']; if(!empty($aid)) { $sql = "UPDATE vote SET Votename= '".$votename."', Starttime='".$starttime."', Endtime='".$endtime."', Totalcount='".$totalcount."', Votenote='".$votenote."' WHERE aid='".$aid."'order by aid desc limit 1;"; $result = mysql_query($sql); if(!empty($result)){ echo '<script>alert(\'数据保存成功\');</script>'; echo "您的调查问卷已生效!"; } else { echo '<script>alert(\'数据保存失败\');</script>'; exit(); } } else{ echo '<script>alert(\'调查异常\');</script>'; exit(); } ?>
验证是否成功:http://localhost:8080/diaocha/admin.php?aid=1
(注意需要加上?aod=1)格式为英文格式
按下保存调查数据按键的时候:会出现
会出现您的调查问卷已生效
3、view.php
<?php $voteitem = $_POST['voteitem']; $con = mysql_connect('localhost','root','root')or die("could not connect database");//密码用户名按照自己的修改 mysql_query("set names utf8"); mysql_select_db('cms_vote')or die("could not select database"); $sql="SELECT *FROM vote"; $result = mysql_query($sql,$con); $arr = mysql_fetch_array($result); $xmlstr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; $xmlstr.=$arr['Votenote']; $xml = simplexml_load_string($xmlstr); $b[]=Array(); $a[]=Array(); for($i=0;$i<5;$i++){ $b[$i]=$xml->movie[$i]->count; |