數(shù)據(jù)庫設(shè)計(jì)
代碼
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
//從調(diào)研題目表中找出題目代號和名稱
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="查看結(jié)果" id="check" ></a>
</form>
</body>
</html>
result.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>查看結(jié)果</title>
<style>
.x
{
float:left;}
</style>
</head>
<body>
<?php
include("../inc/common.inc.php");
include("../inc/function.php");
//從調(diào)研題目表中找出題目代號和名稱
arr=
sql);
arr['title'];
echo "<div><h2>{sqlxx="select * from vote_option where title='{
arrxx=
sqlxx);
//計(jì)算總?cè)藬?shù):
tmmc}'";
ms->qrow($sqlzs);
foreach (v)
{
v['option'];//調(diào)研項(xiàng)目名稱
v['number'];//選擇該項(xiàng)的人數(shù)
//判斷總?cè)藬?shù)是否為0
if(bfb = 0;
}
else
{
number/$zrs['sum'])*100;//求百分比
}
bfb,2); //取小數(shù)點(diǎn)后兩位
echo "<div>
<span class='x'>{bfb}%; height:10px; background-color:#FF8040'> </div>
</div>
<span class='x'>人數(shù):{bfb}%</span><br />
</div><br />";
}
?>
<br />
<a href="index.php"><input type="button" value="返回"></a>
</body>
</html>