Easy Tutorial
❮ Func Mysqli Real Connect Func Array Unshift ❯

PHP mysqli_next_result() Function

PHP MySQLi Reference Manual

Execute multiple queries against the database. Use the mysqli_next_result() function to prepare the next result set:

<?php 
// Assume database username: root, password: 123456, database: tutorialpro 
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 

$sql = "SELECT name FROM websites ORDER BY alexa;";
$sql .= "SELECT app_name FROM apps";

// Execute multiple queries
if (mysqli_multi_query($con, $sql))
{
    do
    {
        // Store the first result set
        if ($result = mysqli_store_result($con))
        {
            while ($row = mysqli_fetch_row($result))
            {
                printf("%s", $row[0]);
                echo "<br>";
            }
        }
    } while (mysqli_next_result($con));
}

mysqli_close($con);
?>

Definition and Usage

The mysqli_next_result() function prepares the next result set from mysqli_multi_query().


Syntax

Parameter Description
connection Required. Specifies the MySQL connection to use.

Technical Details

Return Value: Returns TRUE on success or FALSE on failure.
PHP Version: 5+
--- ---
❮ Func Mysqli Real Connect Func Array Unshift ❯