导航首页 » 技术教程 » PHP:MySQL函数mysql_fetch_row()的用法
PHP:MySQL函数mysql_fetch_row()的用法 155 2023-12-14   

mysql_fetch_row

(PHP 4, PHP 5)

mysql_fetch_row — 从结果集中取得一行作为枚举数组

说明

array mysql_fetch_row ( resource $result )

返回根据所取得的行生成的数组,如果没有更多行则返回 FALSE

mysql_fetch_row() 从和指定的结果标识关联的结果集中取得一行数据并作为数组返回。每个结果的列储存在一个数组的单元中,偏移量从 0 开始。

依次调用 mysql_fetch_row() 将返回结果集中的下一行,如果没有更多行则返回 FALSE

参见 mysql_fetch_array(),mysql_fetch_assoc(),mysql_fetch_object(),mysql_data_seek(),mysql_fetch_lengths() 和 mysql_result()。

参数

result

resource 型的结果集。此结果集来自对 mysql_query() 的调用。

返回值

Returns an numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows.

mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

范例

Example #1 Fetching one row with mysql_fetch_row()

<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}
$row = mysql_fetch_row($result);

echo $row[0]; // 42
echo $row[1]; // the email value
?>

注释

Note: 此函数将 NULL 字段设置为 PHP NULL 值。

参见

mysql_fetch_array() - 从结果集中取得一行作为关联数组,或数字数组,或二者兼有 mysql_fetch_assoc() - 从结果集中取得一行作为关联数组 mysql_fetch_object() - 从结果集中取得一行作为对象 mysql_data_seek() - 移动内部结果的指针 mysql_fetch_lengths() - 取得结果集中每个输出的长度 mysql_result() - 取得结果数据


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103