(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() - 取得結果數據