Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    34
    Thanks
    15
    Thanked 0 Times in 0 Posts

    help with paging.

    Hi, I need 3 par to query my database, how do i create a paging system for this query.

    Please note that the id is going bigger when going next, smaller when going previous page and the next id might be belong to the same user or album.


    Code:
    Select * from gallery_image where id = '$image_id' and album_id = '$album_id' and profile_id = '$profile_id'  Limit 1

  • #2
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Code:
    //get next
    "Select id from gallery_image where id > '$image_id' and album_id = '$album_id' and profile_id = '$profile_id' order by date asc Limit 1"
    
    
    //get previous
    "Select id from gallery_image where id < '$image_id' and album_id = '$album_id' and profile_id = '$profile_id' order by date desc Limit 1"

    I'm no expert, but this one of the best way that i can think of, if anyone of your here knows a better method, please share with us, i am interested too.

  • Users who have thanked kokjj87 for this post:

    uncleroxk (12-17-2008)

  • #3
    Regular Coder lokeshshettyk's Avatar
    Join Date
    Aug 2008
    Location
    On the way to the moon!
    Posts
    157
    Thanks
    5
    Thanked 20 Times in 20 Posts
    kokjj87, good one provided the '$image_id' is some kinda auto-increment data type in the DB? is that so uncleroxk?

    Cheers

  • #4
    New Coder
    Join Date
    Nov 2008
    Posts
    34
    Thanks
    15
    Thanked 0 Times in 0 Posts
    yea.. the $image_id is increasing...

  • #5
    Regular Coder lokeshshettyk's Avatar
    Join Date
    Aug 2008
    Location
    On the way to the moon!
    Posts
    157
    Thanks
    5
    Thanked 20 Times in 20 Posts
    if the image field in the DB is a number field,

    You may also try

    Next - where id = '($image_id+1)'
    Prev - where id = '($image_id-1)'

    I am just giving you options

    Cheers


  •  

    Posting Permissions

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