SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Next Previous pageination help

    Hi,

    I have the following:

    SELECT id, title FROM pictures WHERE id='$pic'
    Now that shows the picture, how can I creat a pagination thing of this so under each picture I have have a next and previous link so that it shows the next and previous pictures in the database.

    This means the next id up in the table and the next id down in the table for the next and previous pagination thing.

    Please help!

    Thanks.

  2. #2
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do a search in this forum, this question has been answered so many times before.
    David

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the great help. I always do a few searches before starting a thread and I didn't find what I was looking for.

    All I want is to throw an id at the database and then receive the previous and next ids from that id I had thrown at the database and then use that dataset so that I can product previuos and next links.

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I now know how to get the previous and next rows but it involves 2 new querys.

    These are:

    Previous ID:

    SELECT id FROM $mytable WHERE id < $id ORDER BY ID DESC LIMIT 1;
    Next ID:

    SELECT id FROM $mytable WHERE id > $id ORDER BY ID ASC LIMIT 1;
    Is there a way of doing it with just 1 query?

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have done it now. I decided to just use the 2 queries.

    Thanks for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •