设为首页 加入收藏

TOP

使用php+mysql+xml完成一个调查问卷(二)
2019-08-15 23:31:40 】 浏览:83
Tags:使用 php mysql xml 完成 一个 调查 问卷
;">

</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">&nbsp;</td>
<td><input type="submit" name="Submit" value="保存调查数据">
</td>
</tr>

<tr>
<td colspan="2">&nbsp;</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;

首页 上一页 1 2 3 4 5 6 下一页 尾页 2/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[PHP]算法-跳台阶问题的PHP实现 下一篇[PHP]算法-队列结构的PHP实现

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目