View Full Version : help with paging.
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
12-16-2008, 06:17 PM
"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"
"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.
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?
12-18-2008, 11:24 AM
yea.. the $image_id is increasing... :D
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
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.