Paul Savage (lostaddiction) wrote in php_dev,
Paul Savage
lostaddiction
php_dev

Prev/Next item with MySQL

[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
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 6 comments