\n \n
\nhljs.highlightAll();\n\n```\n \n
\n
\n \nPHP mysqli_next_result() Function | Tutorial
\nPHP mysqli_next_result() Function: This function is used to move the result pointer of a multiple query execution in PHP.
\nSyntax
\n<?php mysqli_next_result($link); ?>\n Parameters
\n| Parameter | \nDescription | \n
|---|---|
| $link | \nThe database connection link identifier returned by mysqli_connect() or mysqli_init(). | \n
Return Value
\nReturns TRUE on success or FALSE on failure.
\nExample
\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
YouTip