Shaolin
02-12-2009, 12:58 PM
Hi Guys
I am working on a pagination class for my website. I want to display the amount of records viewable by the user and the current amount of recoords being viewed (e.g. Mail 50 of 132). Note that the user can view a max of 50 records per page. I know how to workout the total amount of records viewable by using the following query:
SELECT COUNT(mail_id) FROM mail WHERE user_id='1';
My problem is how I should workout the current amount of records being viewed. Here is the query I have at the moment:
SELECT * FROM mail WHERE user_id='1' AND LIMIT 100, 150;
My question is how can I count ALL the records starting from 0 upto the max LIMIT ? So in the example above the max LIMIT is set to 150 but the real amount of records viewable is 132. I hope that makes sense.
I am working on a pagination class for my website. I want to display the amount of records viewable by the user and the current amount of recoords being viewed (e.g. Mail 50 of 132). Note that the user can view a max of 50 records per page. I know how to workout the total amount of records viewable by using the following query:
SELECT COUNT(mail_id) FROM mail WHERE user_id='1';
My problem is how I should workout the current amount of records being viewed. Here is the query I have at the moment:
SELECT * FROM mail WHERE user_id='1' AND LIMIT 100, 150;
My question is how can I count ALL the records starting from 0 upto the max LIMIT ? So in the example above the max LIMIT is set to 150 but the real amount of records viewable is 132. I hope that makes sense.