PHP mysql_fetch_row() 函数
定义和用法
mysql_fetch_row() 函数从结果集中取得一行作为数字数组。
Syntax
mysql_fetch_row(data)
Parameters | Description |
---|---|
data | Required. The data pointer to use. This data pointer is returned from mysql_query(). |
Description
mysql_fetch_row() from and result identifier data Gathers a row of data from the associated result set and returns it as an array. Each column of the result is stored in an element of the array, starting from 0.
Sequentially calling mysql_fetch_row() will return the next row in the result set, or FALSE if there are no more rows.
Return Value
Returns an array generated based on the fetched row, or false if there are no more rows.
Example
<?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); ?>
Output:
Array ( [0] => Adams [1] => John [2] => London )