Name
mysql_fetch_row
Synopsis
array mysql_fetch_row(qresource query
)
Returns a
numerically indexed array that contains the next available row from
the result set associated with the parameter
query
. The internal pointer associated
with the result set is then incremented, so that the next call to
this function will retrieve the next row. The
query
resource handle is returned from a
prior call to mysql_query( )
or
mysql_unbuffered_query( )
. Returns
false
when no more rows are available.
The function behaves identically to mysql_fetch_array(
)
when its second parameter is set to
MYSQL_NUM
. Unlike mysql_fetch_assoc(
)
(and mysql_fetch_array( )
with the
MYSQL_BOTH
or MYSQL_ASSOC
second parameter), the array returned by mysql_fetch_row(
)
contains all the attributes of the result set, even if
some attributes have the same name.
Example
<?php $query = "SELECT * FROM presents"; $connection = mysql_connect("localhost", "fred", "shhh"); mysql_select_db("wedding", $connection); $result = mysql_query($query, $connection); while ($row = mysql_fetch_row($result)) { for($x=0;$x<mysql_num_fields($result);$x++) echo $row[$x] . " "; echo "\n"; } ?>
Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.