Prev/Next item with MySQL
Date: 04/19/09
(PHP Development) Keywords: php, mysql, database, sql
[solved, thanks to synergetic]
HiGuys,
Needing a bit of help with MySQL queries. Hopefully someone has the answer, or a pointer at least :)
Say I have a page displaying an item, www.domain.com/item.php?id=12 and at the bottom of that page i want to have a Previous link and a Next link which will link to the previous and next item in the database, how do i call the item numbers? I don't want to just do $id - 1 or +1 becausethe next item might be number 14 for example, not 13.
So before the links are displayed, i need some way of saying the id is 12, look at what the next number is in the id column and select that one. So it's not just a prev/next page link, but prev/next item in the DB link.
Hopefully my laymans terms aren't too confusing!
Any ideas? :)
many thanks,
Paul
Source: http://php-dev.livejournal.com/81861.html