Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/170085-how-would-i-do-pagination-in-php/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.