PHP Query Polling exercise (0508), php0508_php tutorial

Source: Internet
Author: User

PHP Query Polling exercise (0508), php0508


Practice Topics:

Solving:

Method One:

1. Poll Main Page:

 
  Vote
 
  Query ($sql, 1);//1 represents the type of $sql}header ("location:TouPiao.php"); >

3. Establish a class to access the database, encapsulated for reference:

 
  Host, $this->uid, $this->password, $db);//Determine connection error!mysqli_connect_error () or Die ("Connection failed! ");//Execute SQL statement $result= $dbconnect->query ($sql);//Determine SQL statement type if ($type ==0) {//If the query statement returns a two-dimensional array of result sets return $result Fetch_all ();} else{//if it is a different statement, returns TRUE or Falsereturn $result;}}}

  Method Two:

1. Poll Main Page:

 
  Vote

2. Processing the polling page:

 
  Query ($sql, 1);//1 represents the type of $sql}header ("location:TouPiao.php"); >

3. View the poll results page:

 
  View Results
 
  Query ($sql); $tmmc = $arr [0][1];echo]

{$TMMC}:

";//Export the option contents from the Research options table: $SQLXX =" SELECT * from Diaoyanxuanxiang where timudaihao= ' {$arr [0][0]} ' "; $arrxx = $db->query ($ SQLXX);//Calculate total number of people: $sqlzs = "Select sum (Numbers) from Diaoyanxuanxiang where timudaihao= ' {$arr [0][0]} '"; $zrs = $db Query ($sqlzs), foreach ($arrxx as $v) {$name = $v [1];//research project Name $number = $v [2];//Select the number of people//determine if the total number is 0 if ($zrs [0][0]==0) { $BFB = 0; } else { $BFB = ($number/$ZRS [0][0]) *100;//percent } $bfb =round ($BFB, 2);//two digits after decimal point echo "{$ Number} {$bfb}%

";}? >

  

Page Display results:

 

http://www.bkjia.com/PHPjc/1125074.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125074.html techarticle PHP Query Polling exercise (0508), php0508 Practice topic: Problem Solving: Method One: 1. Poll Main Page:! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://w ...

  • 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.