Vote
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<style type= "Text/css" >
#list {width:250px; height:200px}
#jieguo {width:250px; height:200px}
. X{float:left}
</style>
<body>
<form action= "chuli.php" method= "POST" >
<?php
Include (".. /dbda.php ");
$db = new Dbda ();
$sql = "SELECT * from Diaoyantimu limit 0,1";
$attr = $db->query ($sql);
$TMMC = $attr [0][1];
$TMDH = $attr [0][0];
echo "<div> title: {$tmmc}</div>";
$SQLXX = "SELECT * from Diaoyanxuanxiang where Timudaihao = ' {$TMDH} '";
$attrxx = $db->query ($SQLXX);
echo "<div id= ' list ' >";
foreach ($attrxx as $v)
{
echo "<div>
<input type= ' checkbox ' value= ' {$v [0]} ' name= ' xx[] '/>
<span>{$v [1]}</span>
</div> ";
}
?>
<input type= "Submit" value= "Submission"/>
<input type= "button" value= "View results" id= "check" onclick= "Showjieguo ()"/>
</form>
</div>
<div id= "Jieguo" style= "Display:none" >
<?php
$sqlsum = "Select sum (Numbers) from Diaoyanxuanxiang where Timudaihao = ' {$TMDH} '";
$attrsum = $db->query ($sqlsum);//All numbers
foreach ($attrxx as $v)
{
$name = $v [1]; Option name
$number = $v [2]; The number of people who selected the item
$BFB = ($number/$attrsum [0][0]) *100;
$BFB = Round ($BFB, 2); Take two digits after the decimal point
echo "<div style= ' width:250px; height:30px ' >
<span class= ' x ' >{$name}</span>
<div class= ' x ' style= ' width:100px; height:8px; border:1px solid Red ' >
<div style= ' width:{$bfb}%; height:8px; Background-color:red ' ></div>
</div>
<span class= ' x ' >{$number} </span>
<span class= ' x ' >{$bfb}%</span>
</div> ";
}
?>
<input type= "button" value= "return" id= "Fanhui" onclick= "showlist ()"/>
</div>
<script type= "Text/javascript" >
function Showjieguo ()
{
document.getElementById ("list"). Style.display = "None";
document.getElementById ("Jieguo"). Style.display = "block";
}
function Showlist ()
{
document.getElementById ("list"). Style.display = "block";
document.getElementById ("Jieguo"). Style.display = "None";
}
</script>
</body>
<?php
$attr = $_post["xx"];
Include (".. /dbda.php ");
$db = new Dbda ();
foreach ($attr as $v)
{
$sql = "Update Diaoyanxuanxiang set Numbers = numbers+1 where Ids = ' {$v} '";
$db->query ($sql, 0);
}
Header ("location:test.php");
PHP 14th session