定义
mysqli_next_result()函数从mysqli_multi_query()准备下一个结果集。
语法
面向对象的风格:
bool mysqli::next_result ( void )
程序风格:
bool mysqli_next_result ( mysqli $link )
参数
参数
是否必须
描述
link
需要。
MySQL连接使用
返回值
成功返回TRUE,失败返回FALSE。
实例
以下代码使用mysqli_next_result()函数准备下一个结果集。
// http://www.manongjc.com/article/1684.html
// 作者:码农教程
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT name FROM emp;SELECT Country FROM emp";
if (mysqli_multi_query($con,$sql)){
do{
// Store first result set
if ($result=mysqli_store_result($con)){
while ($row=mysqli_fetch_row($result)){
print $row[0];
print "\n";
}
}
}while (mysqli_next_result($con));
}
mysqli_close($con);
?>