Execute multiple queries against the database. Please use the mysqli_next_result() function to prepare the next result set:
<?php // Assume database username: root, password: 123456, database: CODERCTO $con=mysqli_connect("localhost","root","123456","CODERCTO"); 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);?>
The mysqli_next_result() function prepares the next result set for mysqli_multi_query().
mysqli_next_result( connection ) ;
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
Return value: | Returns TRUE if successful and FALSE if failed. |
---|---|
PHP version: | 5+ |