johnsmith153 Posted August 13, 2009 Share Posted August 13, 2009 Hi, I have a db with 2000 records (can vary). Pagination: I need to show user number of records in the db then display 100 per page. What is the best method: (1) dump entire db to PHP then sort through records, only displaying 100. (2) Somehow find out number of records in the db (in this case 2000) then return TOP 100 only. It is possible the table could hold 500,000 records at one point. Quote Link to comment https://forums.phpfreaks.com/topic/170085-how-would-i-do-pagination-in-php/ Share on other sites More sharing options...
.josh Posted August 13, 2009 Share Posted August 13, 2009 http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/170085-how-would-i-do-pagination-in-php/#findComment-897250 Share on other sites More sharing options...
alex3 Posted August 13, 2009 Share Posted August 13, 2009 There are loads of pagination tutorials out there, but for your problem, I would number 2. Number 1 can cause a lot of information to be caught up in the memory, a vast majority of which you won't end up using so it's a waste. It's much less of a CPU/memory drain to calculate how many rows there are in the table (a simple SQL statement) and grab the ones that are required. Quote Link to comment https://forums.phpfreaks.com/topic/170085-how-would-i-do-pagination-in-php/#findComment-897274 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.