PHP mysqli_next_result () function
Execute multiple queries against the database. Use mysqli_next_result () function to prepare for the next set of results:
<?php // 假定数据库用户名:root,密码:123456,数据库:w3big $con=mysqli_connect("localhost","root","123456","w3big"); if (mysqli_connect_errno($con)) { echo "连接 MySQL 失败: " . mysqli_connect_error(); } $sql = "SELECT name FROM websites ORDER BY alexa;"; $sql .= "SELECT app_name FROM apps"; // 执行多个查询 if (mysqli_multi_query($con,$sql)) { do { // 存储第一个结果集 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
mysqli_next_result () function mysqli_multi_query () to prepare the next result set.
grammar
mysqli_next_result( connection ) ;
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 5+ |
PHP MySQLi Reference Manual