PHP mysql_fetch_row() 函數
定義和用法
mysql_fetch_row() 函數從結果集中取得一行作為數字數組。
語法
mysql_fetch_row(data)
參數 | 描述 |
---|---|
data | 必需。要使用的數據指針。該數據指針是從 mysql_query() 返回的結果。 |
說明
mysql_fetch_row() 從和結果標識 data 關聯的結果集中取得一行數據并作為數組返回。每個結果的列儲存在一個數組的單元中,偏移量從 0 開始。
依次調用 mysql_fetch_row() 將返回結果集中的下一行,如果沒有更多行則返回 FALSE。
返回值
返回根據所取得的行生成的數組,如果沒有更多行則返回 false。
實例
<?php $con = mysql_connect("localhost", "hello", "321"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person WHERE Lastname='Adams'"; $result = mysql_query($sql,$con); print_r(mysql_fetch_row($result)); mysql_close($con); ?>
輸出:
Array ( [0] => Adams [1] => John [2] => London )