Page 1 of 1
Select specific record
Posted: Wed Aug 04, 2010 4:30 pm
by thomas49th
Hi, I could use
while($row = mysql_fetch_rows($result)){
echo "{$row[0]};";
}
and that would echo the first field of all records found
BUT what is I want to select a specific record. Ie the 5th one down. I cannot do
$row = mysql_fetch_rows($result)
echo "{$row[4][0]};";
or echo "{$row[0][4]};";
How do I achieve what I want to do
Thanks
Thomas
Re: Select specific record
Posted: Wed Aug 04, 2010 5:48 pm
by superdezign
You would specify that in your query.
Code: Select all
select * from `table_name` limit 1, 5
Also, I don't think mysql_fetch_rows() is a real function...
Re: Select specific record
Posted: Wed Aug 04, 2010 6:07 pm
by AbraCadaver
I'm not sure why you want to do this, but in general superdezign is spot on. Retrieve what you need in the query. However, if you need many rows, but just for a certain piece of code you need a specific row then use: mysql_data_seek().
Re: Select specific record
Posted: Wed Aug 04, 2010 6:27 pm
by thomas49th
No No, I can get the records out I want using
while($row = mysql_fetch_rows($result)){
echo "{$row[0]};";
}
to print them out, but I want to just print a specific one, for example record number 3... not all 6. Out of the records found, how do I select a specific one to print to screen
Thanks
Thomas

Re: Select specific record
Posted: Wed Aug 04, 2010 6:35 pm
by AbraCadaver
thomas49th wrote:No No, I can get the records out I want using
while($row = mysql_fetch_rows($result)){
echo "{$row[0]};";
}
to print them out, but I want to just print a specific one, for example record number 3... not all 6. Out of the records found, how do I select a specific one to print to screen
)
Just what I told you
Code: Select all
mysql_data_seek($result, 4);
$row = mysql_fetch_array($result);
Re: Select specific record
Posted: Wed Aug 04, 2010 6:44 pm
by thomas49th
Ahh sorry
Will try tomorrow
Thanks
Thomas