Poll categories
<! DOCTYPE html>PHP$db=NewMysqli ("localhost", "root", "root", "db_0808");$sql= "SELECT * FROM Fenlei";$result=$db->query ($sql);$data _c=$result-Fetch_all ();? ><table border= "1" > <?PHPforeach($data _c as $i){ Echo"<tr><th><a href= ' vote.php?id={$i[0]} &is_radio={$i[2]} ' >{$i[1]} </a></th></tr> "; }?></table></body>Voting interface
<! DOCTYPE html>PHP$id=$_get[' ID '];$is _radio=$_get[' Is_radio '];$db=NewMysqli ("localhost", "root", "root", "db_0808");$sql= "SELECT * from Toupiao WHERE category_id= ' {$id}‘";$result=$db->query ($sql);$data=$result-Fetch_all ();><form action= "tongji.php" method= "POST" ><table> <tr> <td> name </td> <t D> votes </td> </tr> <?PHPif($is _radio==1){ foreach($data as $i){ Echo"<tr> <td>{$i[1]}</td> <td><input type= ' Radio ' name= ' r ' value= ' {$i[0]} ' ></td> </tr>"; } }Else{ foreach($data as $i){ Echo"<tr> <td>{$i[1]}</td> <td><input type= ' checkbox ' name= ' r[] ' value= ' {$i[0]} ' ></td> </tr>"; } } ?></table> <input type= "Submit" value= "Submission" ></form></body>Voting processing
<! DOCTYPE html>PHP//$db = new mysqli ("localhost", "root", "root", "db_0808");require_once".. /zy/yin.class.php ";$db=NewYIN ();$ip=$_server[' REMOTE_ADDR '];//Get IP$sql= "SELECT count (*) from table2 where ip= ' {$ip}‘";$data=$db->strquery ($sql);if($data! = ' 0 '){ Echo"Everyone can only vote once a day.";$r=$_post[' R ']; if(Is_array($r)){ $s=implode(‘,‘,$r); $sq= "SELECT * from Toupiao where ID in ({$s})"; }Else{ $sq= "SELECT * from Toupiao where id = {$r}"; } $qurle=$db->query ($sq); foreach($qurle as $i){ Echo"<tr><td>{$i[1]} </td><td>{$i[2]} </td></tr> "; }}Else{ $sql= "INSERT into table2 VALUES (null, ' {$ip} ', DEFAULT) '; $squel=$db->strquery ($sql, 0); if($squel){//$upsql =update table_name Set votes = votes + 1 where ...//then insert the data into the Table2$r=$_post[' R '];if(Is_array($r)){ $s=implode(‘,‘,$r); $sql= "Update Toupiao set count= (count+1) where ID in ({$s})";}Else{$sql= "Update Toupiao set count= (count+1) where id = {$r}";}$data=$db->query ($sql, 0);if($data){//echo "Success"; if(Is_array($r)){ $s=implode(‘,‘,$r); $sq= "SELECT * from Toupiao where ID in ({$s})"; }Else{ $sq= "SELECT * from Toupiao where id = {$r}";} $qurle=$db->query ($sq); foreach($qurle as $i){ Echo"<tr><td>{$i[1]} </td><td>{$i[2]} </td></tr> "; }} }}?></table></body>PHP Voting system