Paul Savage (lostaddiction) wrote in php_dev,
Paul Savage

Prev/Next item with MySQL

[solved, thanks to synergetic]


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, 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,

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded