1. php-get MySQL database query result rows MySQL database download 64-bit SQL DB instance download SQL database patch Download

Source: Internet
Author: User
One

First you need to define a database interface function that can be saved as a single PHP page


    
     functiondb_connect() {$result = new mysqli('数据库地址', '账号', '密码', '库名');//连接数据库if (!$result) {      returnfalse;//连接失败   }   return$result;//返回数据库对象}?>

Two

In another PHP page, the first use of the include函数 PHP page contains the above, it is necessary to ensure that the above interface functions can be called correctly

   !--? php    function   Output_rows   ( $seller _id )  {  $conn  = Db_connect (); //Connect to database   if  (!  $conn )        {//cannot connect to database   echo   "can not connect to MySQL" ;  return      ' Fail_mysql ' ;  $result  =  $conn ->query ( "select * from T_order WHERE seller_id= '" .  $seller _id .  ' "); //Query data   Echo    $result ->num_rows; //Output lines } ?     

By invoking the functions defined above, you can display the number of rows of SQL query results by querying the $result = $conn->query("SELECT * FROM t_order WHERE seller_id= '". $seller_id."' "); database, querying t_seller seller_id all rows that are equal in the table, $seller_id assigning the result set $result , and then by using the $result->num_rows number of rows that can obtain the results of the query, using the echoPerform output display

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the 1, php-get MySQL database query results rows, including the MySQL database content, I hope the PHP tutorial interested in a friend helpful.

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