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
Select specific record
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Select specific record
You would specify that in your query.
Also, I don't think mysql_fetch_rows() is a real function...
Code: Select all
select * from `table_name` limit 1, 5- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Select specific record
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().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
thomas49th
- Forum Newbie
- Posts: 11
- Joined: Wed Aug 04, 2010 4:29 pm
Re: Select specific record
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
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
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Select specific record
Just what I told youthomas49th 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
)
Code: Select all
mysql_data_seek($result, 4);
$row = mysql_fetch_array($result);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
thomas49th
- Forum Newbie
- Posts: 11
- Joined: Wed Aug 04, 2010 4:29 pm
Re: Select specific record
Ahh sorry
Will try tomorrow
Thanks
Thomas
Will try tomorrow
Thanks
Thomas