English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP mysqli_more_results() function

PHP MySQLi Reference Manual

mysqli_more_results() functionCheck if there are more query results in batch queries

Definition and usage

 Check if there are more query result sets after the previous call to mysqli_multi_query() function. 

Syntax

mysqli_more_results($con)

Parameter

Serial numberParameters and descriptions
1

con(Required)

This is an object representing the connection with the MySQL Server.

Return value

 If there are more result sets that can be read after the previous call to the mysqli_multi_query() function, it returns TRUE, otherwise it returns FALSE.

PHP version

This function was originally introduced in PHP version5introduced and can be used in all higher versions.

Online Example

The following examples demonstratemysqli_more_results()Usage of Function (Procedural Style)-

<?php
   //Establish Connection
   $con = mysqli_connect("localhost", "root", "password", "test");
   //Execute Multiple Queries
   $query = "SELECT * FROM players;SELECT * FROM emp";
   mysqli_multi_query($con, $query);
   do{
      $result = mysqli_use_result($con);
      while($row = mysqli_fetch_row($result)){
         print("Name:  ".$row[0]."\n");
         print("Age:  ".$row[1]."\n");
         print("\n");
      }
      if(mysqli_more_results($con)){
         print("::::::::::::::::::::::::::::::\n");
      }
   }while(mysqli_next_result($con));
   mysqli_close($con);
?>

Output Result

Name:  Dhavan
Age: 33
Name:  Rohit
Age: 28
Name:  Kohli
Age: 25
::::::::::::::::::::::::::::::
Name:  Raju
Age: 25
Name:  Rahman
Age: 30
Name:  Ramani
Age: 22

Online Example

In an object-oriented style, the syntax of this function is$con-> more_results();.The following is an example of this function in an object-oriented style;

<?php
   $con = new mysqli("localhost", "root", "password", "test");
   //Multiple Queries
   $res = $con-> multi_query("SELECT * FROM players;SELECT * FROM emp");
   do {
      $result = $con-> use_result());
      while($row = $result-> fetch_row());
         print("Name:  ".$row[0]."\n");
         print("Age:  ".$row[1]."\n");
         print("\n");
      }
      if($con-> more_results());
         print("::::::::::::::::::::::::::::::\n");
      }
   }-> next_result());
   //Close Connection
   $res = $con -> close();
?>

Output Result

Name:  Dhavan
Age: 33
Name:  Rohit
Age: 28
Name:  Kohli
Age: 25
::::::::::::::::::::::::::::::
Name:  Raju
Age: 25
Name:  Rahman
Age: 30
Name:  Ramani
Age: 22

PHP MySQLi Reference Manual