...

View Full Version : help with paging.



uncleroxk
12-16-2008, 05:47 PM
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.



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

kokjj87
12-16-2008, 06:17 PM
//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.

lokeshshettyk
12-17-2008, 09:33 AM
kokjj87, good one provided the '$image_id' is some kinda auto-increment data type in the DB? is that so uncleroxk?

Cheers :)

uncleroxk
12-18-2008, 11:24 AM
yea.. the $image_id is increasing... :D

lokeshshettyk
12-18-2008, 12:21 PM
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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum