PHP mysqli_fetch_row() 函数

PHP 教程 · 2019-01-27 22:12:06

从结果集中取得行:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:CODERCTO 
$con=mysqli_connect("localhost","root","123456","CODERCTO"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "连接 MySQL 失败: " . mysqli_connect_error(); 
} 

$sql="SELECT name,url FROM websites ORDER BY alexa";


if ($result=mysqli_query($con,$sql))
{
    // 一条条获取
    while ($row=mysqli_fetch_row($result))
    {
        printf ("%s : %s",$row[0],$row[1]);
        echo "<br>";
    }
    
    // 释放结果集合
    mysqli_free_result($result);
}

mysqli_close($con);
?>

定义和用法

mysqli_fetch_row() 函数从结果集中取得一行,并作为枚举数组返回。

语法

mysqli_fetch_row(result);

参数 描述
result 必需。规定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符。

技术细节

返回值: 返回一个与所取得行相对应的字符串数组。如果在结果集中没有更多的行则返回 NULL。
PHP 版本: 5+

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

查看所有标签

Developing Large Web Applications

Developing Large Web Applications

Kyle Loudon / Yahoo Press / 2010-3-15 / USD 34.99

As web applications grow, so do the challenges. These applications need to live up to demanding performance requirements, and be reliable around the clock every day of the year. And they need to withs......一起来看看 《Developing Large Web Applications》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具