PHP Mysqli Learning (iii) query operations

Source: Internet
Author: User
Tags mysql query mysql connect

Check all:
Fetch_all ()
Mysqli_num
Mysqli_assoc
Mysqli_both

Query one:
Fetch_row ()
FETCH_ASSOC ()
Fetch_object ()
Fetch_array ()
Mysqli_num
Mysqli_assoc
Mysqli_both

To speak in code:

<?PHPHeader(' Content-type:text/html;charset=utf-8 ');$mysqli=Newmysqli ();$mysqli= @Mysqli_connect(' localhost:3306 ', ' root ', ' root ', ' Zhy ');if($mysqli-errno) {     die(' MYSQL CONNECT error--'.$mysqli->connect_errno. ': '.$mysqli-connect_error);}$mysqli->set_charset (' UTF8 ');$sql= ' SELECT * from user ';$mysqli _result=$mysqli->query ($sql);if($mysqli _result){    /******************************************************************** * Query all records * $rows = $mysqli _result->fetch_ All (Mysqli_num); Returns the indexed array by default * $rows = $mysqli _result->fetch_all (MYSQLI_ASSOC); Returns the associative array * $rows = $mysqli _result->fetch_all (mysqli_both); Returns an indexed array and an associative array ********************************************************************///$rows = $mysqli _result->fetch_all ();//Var_dump ($rows);    /** * Query a return index array*/    $rows=$mysqli _result-Fetch_row (); Var_dump($rows); Echo' ; /** * Query a return associative array*/    $rows=$mysqli _result-Fetch_assoc (); Var_dump($rows); Echo' ; /** * Query a return object form*/    $rows=$mysqli _result-Fetch_object (); Var_dump($rows); Echo' ; /** * Query a return associative array method contains three properties * mysqli_num * MYSQLI_ASSOC * Mysqli_both*/    $rows=$mysqli _result-Fetch_array (MYSQLI_ASSOC); Var_dump($rows); Echo' ; /** * Move result set internal pointer*/    $mysqli _result->data_seek (0);  while($rows=$mysqli _result-Fetch_assoc ()) {        Var_dump($rows); Echo' <br/? '; }    $mysqli _result-Free ();}Else{     die(' MYSQL QUERY error--'.$mysqli->errno. ': '.$mysqli-error);}$mysqli->close ();

  

PHP Mysqli Learning (iii) query operations

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.