本人根据php典型模块与项目实战大全此书所完成的一个调查问卷,同时管理员可以进行修改调查内容
同时用到了一个css文件,借鉴于
http://www.wufangbo.com/div-css-vote/
需要5个php文件:admin.php、update.php、view.php、result.php、vote.php、
首先在WWW下新建一个文件夹 此处为名为"diaocha" 本人的端口号为8080
数据库如下:库的名字为 cms_vote 表的名字为:vote
其中Votenote内部的内容为:
<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>
1、admin.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 = $_GET['aid'];
if(!empty($aid)){
$sql='SELECT *FROM vote ';
//WHERE aid=".$aid."';
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result);
}
else{
echo '<script>alert(\'调查异常\');</script>';
exit;
}
?>
<html>
<head>
<table width="98%" border=0 align="center" cellpadding="3" cellpadding="1">
<tr>
<td height="28" ><b>调查管理</b></td>
</tr>
<tr height="200" valign="top">
<form name="form1" method="post" action="update.php">
<input type="hidden" name = "aid" value="<?php echo $aid?>">
<table width="100%" border="0"cellpadding="4" cellspacing="4">
<tr>
<td width="15%" align="center">调查项目:</td>
<td width="85%">
<input name="votename" type="text" id="votename" value="<?php echo $row['Votename'];?>">
</td>
</tr>
<tr>
<td align="center">调查总人数:</td>
<td>
<input name="totalcount" type="text" id="totalcount" value="<?php echo $row['Totalcount'];?>">
</td>
</tr>
<tr>
<td align="center">开始时间:</td>
<td>
<input name="starttime" type="text" id="starttime" value="<?php echo $row['Starttime'];?>">
</td>
</tr>
<tr>
<td align="center">结束时间:</td>
<td>
<input name="endtime" type="text" id="endtime" value="<?php echo $row['Endtime'];?>