YouTip LogoYouTip

Func Mysqli Next Result

```html\n\n \n PHP mysqli_next_result() Function | Tutorial\n \n \n \n \n \n \n \n \n \n @import url('https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.6.0/styles/default.min.css');\n\n
\n \n
\n

PHP mysqli_next_result() Function | Tutorial

\n

PHP mysqli_next_result() Function: This function is used to move the result pointer of a multiple query execution in PHP.

\n

Syntax

\n
<?php mysqli_next_result($link); ?>
\n

Parameters

\n \n \n \n \n \n \n \n \n \n
ParameterDescription
$linkThe database connection link identifier returned by mysqli_connect() or mysqli_init().
\n

Return Value

\n

Returns TRUE on success or FALSE on failure.

\n

Example

\n
<?php\n// Create connection\n$conn = new mysqli("localhost", "username", "password", "database");\n\n// Check connection\nif ($conn->connect_error) {\n    die("Connection failed: " . $conn->connect_error);\n}\n\n// Execute multi-query\n$sql = "SELECT * FROM table1; SELECT * FROM table2";\nif ($conn->multi_query($sql)) {\n    do {\n        // Fetch results from the first query\n        if ($result = $conn->store_result()) {\n            while ($row = $result->fetch_assoc()) {\n                echo "ID: " . $row . " Name: " . $row . "
";\n }\n $result->free();\n }\n\n // Move to the next result set\n if ($conn->more_results()) {\n if (!$conn->next_result()) {\n printf("Next result failedn");\n }\n } else {\n break;\n }\n } while (true);\n} else {\n echo "Error: " . $conn->error;\n}\n\n$conn->close();\n?>
\n

This example demonstrates how to execute multiple queries and fetch results using mysqli_next_result().

\n
\n \n
\nhljs.highlightAll();\n\n```
← Func Mysqli Num FieldsFunc Mysqli Multi Query β†’