数据库设计
代码
index.php
<?php
include("../inc/common.inc.php");
include("../inc/function.php");
if(arr=arr as sql = "update vote_option set number = number+1 where id = '{r=sql);//1代表$sql的类型
}
header ("location:index.php");
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>投票</title>
<style>
.x
{
float:left;}
</style>
</head>
<body>
<form action="" method="post">
<?php
//从调研题目表中找出题目代号和名称
arr=
sql);
arr['title'];
arr['id'];
echo "<div><h2>".sqlxx="select * from vote_option where title='".
arrxx=
sqlxx);
echo "<div id='list'>";
foreach (v)
{
echo "<div><input type='checkbox' value='{v[1]}</div><br />";
}
?>
<input type="submit" value="提交">
<a href="result.php"><input type="button" value="查看结果" id="check" ></a>
</form>
</body>
</html>
result.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>查看结果</title>
<style>
.x
{
float:left;}
</style>
</head>
<body>
<?php
include("../inc/common.inc.php");
include("../inc/function.php");
//从调研题目表中找出题目代号和名称
arr=
sql);
arr['title'];
echo "<div><h2>{sqlxx="select * from vote_option where title='{
arrxx=
sqlxx);
//计算总人数:
tmmc}'";
ms->qrow($sqlzs);
foreach (v)
{
v['option'];//调研项目名称
v['number'];//选择该项的人数
//判断总人数是否为0
if(bfb = 0;
}
else
{
number/$zrs['sum'])*100;//求百分比
}
bfb,2); //取小数点后两位
echo "<div>
<span class='x'>{bfb}%; height:10px; background-color:#FF8040'> </div>
</div>
<span class='x'>人数:{bfb}%</span><br />
</div><br />";
}
?>
<br />
<a href="index.php"><input type="button" value="返回"></a>
</body>
</html>