一个php做的简易的投票系统例子出现的问题
在网页投票后没有票数没有变化,但在数据库里改写票数,网页票数相应变化
代码如下:
<?if($voted && $already_voted){$SetCookie("already_voted","1");}?><html> <head><title>线上投票系统</title></head> <body> <font size=5 color=#0000ff>线上投票系统</font><br><p> 主题:我们选举的班长 <form action="<?echo $PHP_SELF?>" method="POST"> <? mysql_pconnect("LocalHost","root","wuhong"); if($voted && $already_voted) { print("<font size=4 color=#ff0000>你已投上神圣的一票!</font><br><p>\n"); } else if($voted) { if(!mysql_db_query("xyl","update vote_banzhang set vote_number=vote_number+1 where votee='$voted'")) { print mysql_erron().":".mysql_error()."<br>"; } }$result=mysql_db_query("xyl","select sum(vote_number) as sum from vote_banzhang"); if($result) { $sum=(int)mysql_result($result,0,"sum"); mysql_free_result($result); } $result=mysql_db_query("xyl","select * from vote_banzhang order by vote_number DESC"); print "<table border=0><tr><td>选取</td><td>我们的班长</td><td>票数</td></tr>\n"; while($row=mysql_fetch_row($result)) { //print "<tr><td align=center><iput type=radio name=voted value=\"$row[0]\"></td>td>"; //print $row[0]."</td><td align=right>".$row[1]."</td><td>"; //print "</tr>\n"; //print "</table>\n";0 $votee=$row[0];$vote_numbers=$row[1];?> <tr><td align=center> <input type=radio name="voted" value=$row[0]></td> <td> <? echo $row[0]?></td> <td align=right><? echo $row[1]?></td> </tr> <? } ?> </table> <? mysql_free_result($result); ?> <input type=submit value="投票了!"> <input type=reset value="我要重选"> </form> </body></html>