1<body>2<form action= "tpchuli.php" method= "POST" >3<?PHP4 5 $db=NewMysqli ("localhost", "root", "123", "MyDB");6 7 $sql= "SELECT * FROM Diaoyantimu";8 9 $result=$db->query ($sql);Ten One $attr=$result-Fetch_all (); A - foreach($attr as $v) - { the Echo"<div>{$v[1]} </div> "; - - $sxx= "SELECT * from Diaoyanxuanxiang where timudaihao= ' {$v[0]} ' "; - + $rxx=$db->query ($sxx); - $axx=$rxx-Fetch_all (); + A $bs= 0; at if(!Empty($_get["A"])) - { - $bs=$_get["A"]; - } - - $s=$bs==1? " None ":" Block "; in - Echo"<div id= ' Toupiao ' style= ' display:{$s} ' > '; to foreach($axx as $v 1) + { - Echo"<div><input type= ' checkbox ' name= ' tp[] ' value= ' {$v 1[0]} ' />{$v 1[1]} </div> "; the } * Echo"</div>"; $ Panax Notoginseng $s 1=$bs==0? " None ":" Block "; - the //Show Poll Results + Echo"<div id= ' Jieguo ' style= ' display:{$s 1} ' > '; A the foreach($axx as $v 2) + { - $v 2[2];//number of current options $ //Request Total number $ $szrs= "Select sum (Numbers) from Diaoyanxuanxiang where timudaihao= ' {$v[0]} ' "; - $rzrs=$db->query ($szrs); - $azrs=$rzrs-Fetch_row (); the $azrs[0];//Total number - Wuyi $BFB= ($v 2[2]/$azrs[0]) *100; the - Echo"<div>{$v 2[1]} <div style= ' width:100px; height:10px; border:1px solid black; ' ><div style= ' width:{$BFB}%; height:10px; Background-color:red ' ></div></div>{$v 2[2]} {$BFB}%</div> "; Wu } - About Echo"</div>"; $ } - -?> - A<input type= "Submit" value= "vote"/> +<input type= "button" id= "JG" value= "View Results" onclick= "showjg ()"/> the<input type= "button" id= "Fanhui" value= "return" onclick= "SHOWTP ()"/> -</form> $</body> the the<script type= "Text/javascript" > the functionSHOWJG () the { -document.getElementById ("Jieguo"). Style.display= "Block"; indocument.getElementById ("Toupiao"). style.display= "None"; thedocument.getElementById ("JG"). Style.display= "None"; thedocument.getElementById ("Fanhui"). Style.display= "Block"; About the } the the functionSHOWTP () + { -document.getElementById ("Jieguo"). style.display= "None"; thedocument.getElementById ("Toupiao"). Style.display= "Block";Bayidocument.getElementById ("JG"). Style.display= "Block"; thedocument.getElementById ("Fanhui"). style.display= "None"; the } -</script>
1<?PHP2 $attr=$_post["TP"];3 4 $str=implode("‘,‘",$attr);5 6 $sql= "Update Diaoyanxuanxiang set numbers = numbers+1 where IDs in (' {$str}‘)";7 8 $db=NewMysqli ("localhost", "root", "123", "MyDB");9 $db->query ($sql);Ten One Header("Location:toupiao.php?a=1");
Poll Contact Questions