PHP mysqli_next_result() 函数

PHP 教程 · 2019-01-28 09:13:29

执行多个针对数据库的查询。请使用 mysqli_next_result() 函数来准备下一个结果集:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:CODERCTO 
$con=mysqli_connect("localhost","root","123456","CODERCTO"); 
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);
?>

定义和用法

mysqli_next_result() 函数为 mysqli_multi_query() 准备下一个结果集。

语法

mysqli_next_result(connection);

参数 描述
connection 必需。规定要使用的 MySQL 连接。

技术细节

返回值: 如果成功则返回 TRUE,如果失败则返回 FALSE。
PHP 版本: 5+

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Basics of Web Design

Basics of Web Design

Terry Felke-Morris / Addison-Wesley / 2013-1-28 / USD 98.40

Basics of Web Design: HTML5 and CSS3, 2e covers the basic concepts that web designers need to develop their skills: * Introductory Internet and Web concepts* Creating web pages with HTML5* Configurin......一起来看看 《Basics of Web Design》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具