Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-16-2008, 04:47 PM   PM User | #1
uncleroxk
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 15
Thanked 0 Times in 0 Posts
uncleroxk is an unknown quantity at this point
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
uncleroxk is offline   Reply With Quote
Old 12-16-2008, 05:17 PM   PM User | #2
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
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.
kokjj87 is offline   Reply With Quote
Users who have thanked kokjj87 for this post:
uncleroxk (12-17-2008)
Old 12-17-2008, 08:33 AM   PM User | #3
lokeshshettyk
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
lokeshshettyk is an unknown quantity at this point
kokjj87, good one provided the '$image_id' is some kinda auto-increment data type in the DB? is that so uncleroxk?

Cheers
lokeshshettyk is offline   Reply With Quote
Old 12-18-2008, 10:24 AM   PM User | #4
uncleroxk
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 15
Thanked 0 Times in 0 Posts
uncleroxk is an unknown quantity at this point
yea.. the $image_id is increasing...
uncleroxk is offline   Reply With Quote
Old 12-18-2008, 11:21 AM   PM User | #5
lokeshshettyk
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
lokeshshettyk is an unknown quantity at this point
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
lokeshshettyk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:22 AM.


Advertisement
Log in to turn off these ads.