SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

PHP Paging: Breaking records into different pages

If there are more records in a table ( say more than 50) then it will not look nice to display all the records in one page and asking visitors to scroll down to see all the records. This will also slow the process of loading of records. So it is better to break all the collected records into different pages with a fix number of records per page ( say ten records per page) .We have to give navigational link at left and right side saying previous and next page. We also have to give links at the center so the visitor can visit in between pages of his/her choice.

The below menu is further improved if you have more records. For more than 1000 records and if you have 10 records per page then you have to show 100 links at the bottom of the page. That can be further simplified in advanced script to make links in groups. Click here to download the code and check the demo of advanced php paging. But it is better to understand the basic script first.

We can expect our navigational menu at bottom of the page to look like this.


 Name Class Mark
 Babby John Four 69
 Reggid Seven 55
 Herod Eight 79
 Tiddy Now Seven 78
 Giff Tow Seven 88
 Crelea Seven 79
 Big Nose Three 81
 Rojj Base Seven 86
 Tess Played Seven 55
 Reppy Red Six 79
PREV   1  2  3  4 NEXT
    Before going into details of how to write the code, please visit php mysql connection page to check that you have connected to mysql db. Also read the article on how to display data from MySQL table here. We will be using some sql commands like sql limit, order by etc so you can refer them in our sql section.   

Now let us have one table with nearly 35 records. We will use the student table for this and you can use code sample at the end of this tutorial to download the MySQL dump file to create the table along with the script.

The above menu is further improved if you have more records. For more than 1000 records and if you have 10 records per page then you have to show 100 links at the bottom of the page. That can be further simplified in advanced script to make links in groups. Click here to download the code and check the demo of advanced php paging. But it is better to understand the basic script first.    

PHP paging Part II >>

Customizing the paging script with user selection of number or records per page >>

Sorting data by column header in paging script Part III >>

PHP paging demo I >>

Selection of number of records per page in PHP paging demo II >>

Column header sorting demo III >>

Download the ZIP file here  php_paging.php
Participate in active forum on PHP MySQL paging script

Discuss this tutorial at forum


Further readings
Basics of Paging script using PHP MySQL
Limiting number of records per page: Codes : Part II
Sorting the records by column head hyperlinks in paging script
DEMO Sorting records on column head ( or field head)
Selection of number of records per page by user in Paging script
Demo of number of records from a drop down by user in paging script
Advance Php paging script
Tutorial on Advance Php paging script
 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
Date & Time
Array
String Functions
Math Functions
Form Handling
File Handling
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.