php mysqli multiple query example

WBOY
Release: 2016-07-25 09:11:46
Original
1199 people have browsed it

Examples of Mysqli multiple queries in php, interested friends can refer to it.

mysqli_multi_query(mysqli link,string query) executes multiple queries continuously and is based on process msyqli_more_results(mysqli link) mainly determines whether the returned result set has other result sets mysqli_next_result(mysqli link) Get the next result set

Example:

  1. #Connect to database
  2. $link=mysqli_connect("localhost","root","root");
  3. #Select database
  4. $link->select_db("rorely ") or die("could not find database");
  5. #Query database
  6. if($link->multi_query("select * from test;select name ,age ,sex,address from test")){
  7. do{
  8. $result=$link->store_result();
  9. while($row=$result->fetch_row()){
  10. echo "$row[0],$row[1],$row[2], $row[3]
    ";
  11. }
  12. if($link->more_results()) echo "**********
    ";
  13. }while($link- >next_result());
  14. }
  15. $link->close();
  16. ?>
Copy the code

The results are as follows: 1,Jane,26,female 3,Tome,21,male 4,Lily,25,female 5,Lucy,25,female 6,Jim,22,male 7,Jim,22,male ********** Jane,26,female,wenming cun 123# Tome,21,male,wenming cun 32# Lily,25,female,wenming cun 2# Lucy,25,female,wenming cun 2# Jim,22,male,wenmin cun 45# Jim,22,male,wenmin cun 45# li,22,female,wenming cun 23# hj,30,male,wenming cun 23# hj,30,male,wenming cun 23#



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!