PHP mysql_fetch_row() Function
Definition and Usage
The mysql_fetch_row() function retrieves a row from the result set as a numeric array.
Syntax
mysql_fetch_row(data)
Parameters | Description |
---|---|
data | Required. The data pointer to use. This data pointer is from the mysql_query() return result. |
Description
mysql_fetch_row() from and result identifier data Fetches a row of data from an associated result set and returns it as an array. Each column of the result is stored in an element of the array, starting at offset 0.
Calls mysql_fetch_row() in sequence to return the next row in the result set, or FALSE if there are no more rows.
Return Value
Returns an array generated from the retrieved 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 )