If you do not learn, can only show that you do not work hard, only this.
Package Class Dbda page:
<?PHPHeader("Content-type:text/html;charset=utf-8");classdbda{ Public $host= "localhost"; Public $uid= "Root"; Public $pwd= "123"; Public $dbconnect; functionQuery$sql,$type=1,$dbname= "Diaocha") { $this->dbconnect=NewMysqli ($this->host,$this->uid,$this->pwd,$dbname); if(!Mysqli_connect_error()) { $result=$this->dbconnect->query ($sql); if($type==1) { return $result-Fetch_all (); } Else { return $result; } } Else { Echo"Connection Failed"; } }}
Main Page:
<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >PHPinclude"Dbda. CLASS. PHP ";$timu=NewDbda ();$sql= "Select title from Diaoyantimu where Ids=1";$a=$timu->query ($sql);foreach($a as $v){ Echo"{$v[0]} ";}? ><form action= "result1.php" method= "post" ><?PHP$DX=NewDbda ();$sql= "SELECT * from Diaoyanxuanxiang where timudaihao=1";$b=$DX->query ($sql);foreach($b as $n){ Echo"<input type= ' checkbox ' name= ' check[] ' value= ' {$n[0]} ' />{$n[1]} <br/> ";}><input type= "Submit" value= "commit"/><a href= "result.php" ><input type= "button" value= "View results"/> </a></form></div></body>
Click the View Results button (Butturn) effect page:
<body><?PHPinclude"DBDA.class.php";$xx=NewDbda ();//Output Topics$s= "SELECT * from Diaoyantimu where Ids=1";$shuzu=$xx->query ($s);Echo $shuzu[0] [1];//Output Options$sql= "SELECT * from Diaoyanxuanxiang where timudaihao=1";$attr=$xx->query ($sql);$sq= "Select sum (Numbers) from Diaoyanxuanxiang where timudaihao=1";$at=$xx->query ($sq);$total=$at[0] [0];foreach($attr as $v){ $d=($v[2]/$total) *100; Echo"<div> <span style= ' float:left; ' >{$v[1]} </span> <div style= ' width:100px; height:15px; border:1px solid #000000; Float:left ' > <div style= ' width:{$d}%;height:15px; background-color:red; ' > </div> </div>; <span style= ' Float:left ' > {$v[2]}</span> <span style= ' Float:left ' > {$d}%</span> </div>"; }><a href= "prctice.php" ><input style= "Cursor:pointer" type= "button" value= "return"/></a></ Body>
Submit Processing page:
<?PHP//Submitinclude"DBDA.class.php";$DX=NewDbda ();if(!Empty($_post)){$v 1=$_post["Check"];//gets to the arrayVar_dump($v 1);foreach($v 1 as $v 2){ $s= "Update Diaoyanxuanxiang set numbers=numbers+1 where ids={$v 2}"; Var_dump($s); $DX->query ($s, 2); //Var_dump ($dx->query ($s, 0));}}Header("location:result.php");
Case: Voting