PHP Paging: Breaking records into different pages

Paging of records refers to the process of dividing a collection of records or data into smaller, manageable units called pages. Each page typically contains a fixed number of records. This technique is commonly used in database management systems and file systems to organize and retrieve data efficiently.

Navigation in Paging concept

Out of say 100 records we will display the first 1 to 10 records and then give a link at the end to display the next 10 records. On click of this link we will display 11 to 20 records. At the same time the user may like to return to the first 1 to 10 pages so we will be displaying another link saying Previous. So we can move forward or backward to navigate between pages. We can also display links for all the ten pages so users can directly go from 2nd page to 7th page.
Tutorial PHP paging Part II
 Name Class Mark
 Babby John Four 69
 Giff Tow Seven 88
 Crelea Seven 79
 Big Nose Three 81
 Reppy Red Six 79
PREV   1  2  3  4 NEXT
   

Now Check our new code: Bootsrap Paging Classes
We will be using several SQL functions to manage records. Ensure that you have Mysql PDO connection to database. 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.

Advance Php paging 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.

Backend or Frontend Paging

Here we discussed back end paging where data is collected in parts.
How Google Chart is used to create paging at front end
In backend paging each time our script will collect a small chunk of records from the back end and display the same. It goes back again to collect another set of records based on user requirements. Which one is better ?

Number of records

If the number of records is more then use backend scripts to collect based on user selection. Say if you want to display 10 records out of 1000 records then better to go for back end scripts and collect each set of records as and when the user requires.

If we have a total of 30 records and we want to display 10 records per page then we can download all 30 records and show a set of 10 records with the navigation facility. Here we need not run the back end scripts again to collect a different set of 10 records.

Speed

First time loading may take more time but since the operation is at front end so speed will be better if we use front end paging.

Functionality

It is the same in both cases and by using google chart library we can provide a good tool to users, however the same can be achieved by coding or by using different libraries while using back end scripts.
Script Description
Paging ScriptPhp script part of basic paging script ( part II)
user choiceUser can select number of records per page by selecting drop down list
Header controlChange the listing order by clicking the column header
Advance PagingAdvance paging script with outer and inner paging
Ajax PagingPaging without reloading page by using Ajax
Delet RecordAjax paging with record delete option

Demo : Examples using PHP paging script

Demo Example Description
Basic PagingDemo of basic paging script
User SelectionDemo of user selection of number of records per page
Header LinkSorting of paging records order by different column headers
Advance PagingInner and outer links for paging of records in advance paging script
Tutorial PHP paging Part II DEMO : Basic Paging script
DEMO :PHP paging customized II (Number of Records Per Page ) DEMO : Customized sorting in paging script III download Php Paging  Script

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    chirag

    08-04-2012

    it is nice tutorial....
    sourav

    20-09-2012

    Very nice and easy
    Ashahmali

    20-08-2013

    Very good tutorial thank you boss!
    nikhil

    05-09-2014

    very nice tutorial !thanks
    Abshir Ducaale

    19-09-2014

    thanks..great tutorials
    BHARTI

    03-12-2014

    Thank you for lovely tutorial .... and it is so easy...loveit

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer