I'm using a mysql database.
I display the contents of a row by passing the ID through $_GET
e.g. detail.php?ID=15
now I want a "next" and "previous" button on that page.
What's the query to accomplish this?
Just doing $ID+1 and $ID-1 wouldn't work anymore if I deleted rows in the future...
Any suggestion? I searched through the forums but didn't find a solution. (maybe i searched using the wrong keywords)
find following row
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
something like
[mysql_man]union[/mysql_man]
Code: Select all
select * from table_name where id < $id order by id desc limit 1
union select * from table_name where id = $id limit 1
union select * from table_name where id > $id order by id asc limit 1