PHP 14th session

Source: Internet
Author: User

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}&nbsp;</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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.