I am working on a pagination system for my webapp and its causing me alot of headaches at the moment.
The user can view upto 50 records per page. The URL query is like page=1, page=2 etc - To workout the the MIN and MAX values for the mysql LIMIT I multiply the page number by 50 which gives me the MAX amount for the LIMIT, to workout the MIN I minus 50 from the MAX amount. So the query for say page 3 would look something like this:
MAX: 50 x 3 = 150
MIN 150 - 50 = 100
SELECT * FROM table WHERE id='1' LIMIT 100, 150;
Now, I have two problems:
1. The user should be able to view the current set of records he is browsing, e.g. "Viewing 100 of 134 Orders" - How do I workout the current amount of records being viewed ? Iknow how to work out the max, I just use count(*) in mysql.
2. How can I determine whether the previous/next page links should be enabled or disabled ?
Please note that I am trying to avoid using any greedy methods of dealing with this issue (such as caching all the records) because the query is complex and there can potentially be ALOT of data in each table.
Before anyone suggests it, yes I have read the pagination FAQ.