views:

60

answers:

3

Hey, I am wondering how exactly the below pagination systems are set up? In terms of the how the data is displayed, for instance, does BuySellAds load all results in from database and then paginate that data so filter can be done easier? or, do they call the database every time a new page is loaded and then grab the info and display it? I really would like to know how both BuySellAds and Nike make their pagination systems, since I have to make a similar system that has many filters and options to easily sort through the data from a database. I want to accomplish this with php and jquery if that's what I even need to use.

Here is what I am talking about so you can experience it for yourself:

  1. BuySellAds

  2. store.nike.com

Any info/suggestions would be great. Thanks for your input.

A: 

Well, on BuySellAds you can see a big modal box saying "Loading results" whenever you click on a different page. They're using Ajax to get the results from the server and then update the page accordingly.

Jorge
A: 

They both use ajax on every sort action. Don't ever load a humongous amount of data to then crop it in pages with jquery. Bring only what the user will see on the first place and then request for the rest on demand.

Ben
+1  A: 

You don't want to load all results from a database query. You end up just throwing away all that data that was transferred. You set a page size, a default size and/or url parameter, then pass a page number. Then you calculate a limit for your query. For example (without proper sanitation):

$pageSize = 10;
SELECT * FROM MyData LIMIT ($_GET['page']-1)*$pageSize, $pageSize;
Brent Baisley