PHP mysqli_next_result() Function

PHP mysqli_next_result() function prepares the next result set from mysqli_multi_query()

Syntax

bool mysqli_next_result(void);

mysqli_next_result() Function Parameter

ParameterDescription
NANA

mysqli_next_result() Function Return Value

Return Values :Returns TRUE on success or FALSE on failure.

mysqli_next_result() Function Example

<?php
$con = mysqli_get_charset("localhost","user","password","db");

if (mysqli_connect_errno())
{
	echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query  = "SELECT fname,lname from employee;";
$query .= "SELECT grad, dept from department";


if (mysqli_next_result($con, $query)) {
    do {
        // store first result set 
        if ($result = mysqli_store_result($con)) {
            while ($row = mysqli_fetch_row($result)) {
                echo $row[0];
            }
            mysqli_free_result($result);
        }
        }
    } while (mysqli_next_result($con));
}

mysqli_close($con);
?>