【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“showtotal.php”一文,供大家参考学习
<?php
/*
* Created on 2006-11-15
* 投票计数页面
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse -
PHP - Code Templates
*/
?>
<HTML>
<HEAD>
<title>查看投票结果</title>
<link rel="stylesheet" type="text/css" href="css/shared.css">
</HEAD>
<?php
require_once('com/db.php');
$db = new DataAccess();
$sql="select sum(pollnum) as Total_num from book_polltype";
mysql_query("set names 'gbk'");
$result=mysql_query($sql);
$myarray=
mysql_fetch_array($result);
//统计总票数
$Total_num=$myarray["Total_num"];
//echo $Total_num;
$total
sql="select * from book_polltype order by pollnum desc";
$totalresult=mysql_query($totalsql);
if($totalresult)
{
?>
<body>
<center>
<table width="80%" border="0" cellspacing="2" cellpadding="3">
<?php while($myarray=mysql_fetch_array($totalresult))
{
?>
<tr bgcolor="#99ccff">
<td>投票项目类型:
<?php echo $myarray["PollTypeName"];?>
</td>
</tr>
<tr>
<td>投票率:占
<?php
if($Total_num==0) echo 0;
else
echo number_format(100*$myarray["pollnum"]/$Total_num,1);?>%
[该项目得票数:<?php echo $myarray["pollnum"];?>票,
总共:<?php echo $Total_num;?>票]
</td>
</tr>
<?php
}
?>
</table>
<?php
}else{
?>
<p class="text1" align="center">目前还没人投票,谢谢查看<?php
}
?>
<a href ="index.php">返回</a>
</center>
</body>
<
HTML>