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 echo
Perform 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.