Monday, 12 April 2010 06:43
Pagination with PHP, MySQL and AjaxWritten by Miguel
When creating pagination for your website content, there a few factors to consider such as the size and source of the content, the load speed and ease of navigation.
To better explain, I have chosen to write about retrieving data from a SQL database, using PHP. Consider a database table containing information relating to football players in a specific league. The database table could include numerous columns for name, surname, image, player profile, present club, etc. You can see how the database table can easily hold lots of information, especially if you wish to include statistics data for each player.
So you query the database, set your limit for the number of data entries per page, and proceed to create your pagination. By itself, PHP would require that each link of your pagination reload the page with the query and by doing so, you would query the database again and again, and this obviously impacts the speed of navigation.
A combination of PHP and AJAX, enables you to query the database only once, when the page is loaded. Since AJAX is used to split the query results into multiple pages, there is no need to reload the page as you navigate through the query results.
Although there are a number of different methods of combining PHP and AJAX to achieve pagination, I suggest having a look at one or all of the sources below:
PHP MySQL Pagination
Ajax Pagination with Jquery,PHP,Mysql
Latest from Miguel