Re: mysql_fetch_row - how do I fetch a specific row?
| From: | Miles Thompson | Date: | Wed, 16 Jan 2002 20:52:31 +0000 |
| Subject: | Re: mysql_fetch_row - how do I fetch a specific row? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80819@lists.php.net to get a copy of this message | ||
Paul,
The obvious question is "Why do that?" If there is a certain criteria you want to meet, it's generally better to do that in your select statement.
Having got that out of the way,
$result = mysql_query("SELECT * FROM a_table");
$num_rows = mysql_num_rows($result);
returns the number of rows you have fetched, then use mysql_data_seekI() to position the result pointer ...
mysql_data_seek( $result, 3 )
will put you on the 4th row.
It's all at http://www.php.ca/manual/en/function.mysql-data-seek.php,
but I'll repeat, as a rule of thumb, do your work in the select statement, if possible.
Cheers - Miles
At 03:10 PM 1/16/2002 -0500, Phil Schwarzmann wrote:
After I make a query....how do I fetch a specific row from that query ?? Thanks!