Forum Moderators: coopster
I am building a site that displays properties for rent. I have a simple display.php page that pulls all the property data from MySQL and displays it. Here is my issue..
I need a prev / next function on the page so we can scroll through the listings. The record ID's are not 1,2,3 for example...they are more like 33, 46, 95, 105.
Most pagination script assume you are starting at the begining of the list of entries and do
$currid = $id;
$previd = $id -1;
$nextid = $id +1;
etc, etc,
As the ID's are not in order like that, I am not sure how to go about this. What I need is to do this (going by my previous example).....
$currid = 46; // for example
$previd =33;
$nextid =95;
As the records are added and deleted all the time, I need this to find it dynamically on the page as we go. Any suggestions? I would really appreciate it. Thanks
Scott
Watch the "limit 0, 30" "limit 30, 30", "limit 60, 30" and so forth as you go page-1 to page-2 to page-3 respectively having the defaults.
This is basically what you need to pass to your sql query along with everything else, to achieve splitting regardless of custom ids.
$page[1] will contain the id you're coming from, and $page[2] will contain the 'n' or 'p'. I'd use the regular expression once instead of substr() twice (once to get the last character and once to get everything before the last character).