PHP mysqli_next_result() Function
In this chapter you will learn:
- Definition for PHP mysqli_next_result() Function
- Syntax for PHP mysqli_next_result() Function
- Parameter for PHP mysqli_next_result() Function
- Return for PHP mysqli_next_result() Function
- Example - prepare the next result set
Definition
The mysqli_next_result() function prepares the next result set from mysqli_multi_query().
Syntax
Object oriented style
bool mysqli::next_result ( void )
Procedural style
bool mysqli_next_result ( mysqli $link )
Parameter
Parameter | Is required | Description |
---|---|---|
connection | Required. | MySQL connection to use |
Return
It returns TRUE on success and FALSE on failure.
Example
The following code uses mysqli_next_result() function to prepare the next result set.
<?php//jav a2 s . c om
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT name FROM emp;SELECT Country FROM emp";
if (mysqli_multi_query($con,$sql)){
do{
// Store first result set
if ($result=mysqli_store_result($con)){
while ($row=mysqli_fetch_row($result)){
print $row[0];
print "\n";
}
}
}while (mysqli_next_result($con));
}
mysqli_close($con);
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_num_fields() Function
- Syntax for PHP mysqli_num_fields() Function
- Parameter for PHP mysqli_num_fields() Function
- Return for PHP mysqli_num_fields() Function
- Example - returns the number of columns in a result set
- Example - Object oriented style
Home » PHP Tutorial » PHP MySQLi Functions