Advanced Ajax Pagination PHP,MySQL Using jQuery

Ajax Pagination is very useful to show set of data without any page refresh,In ajax pagination request will go async manner so that web request will work parallel with another request.

In previous article you have learned how to do Ajax Pagination with PHP with out any external jquery plugin but here i am creating advanced ajax pagination with simplePagination jquery plugin.

simplePagination.js plugin is useful to display pagination on large data set.You can also create pagination without ajax using simplePagination jquery plugin.Simple pagination is a simple jQuery pagination plugin,which are supporting CSS3 themes and Bootstrap support.You can download from here simplepagination plugin.

This tutorial help you to create ajax pagination with php and MySQL.There are following steps need to create ajax pagination with php and MySQL.

Checkout other tutorials of pagination,

There are following files and folder will participate on ajax pagination with php and mysql

  • db.php : Use to create connection with mysql
  • index.php : Use to show listing of records using php
  • pagination.php : Use to fetch records from database and send to listing page.
  • dist : This folder use to keep simplePagination.js plugin files.

Advanced AJAX Pagination with PHP and Mysql

Step 1: included all js and css files in head section of index file.

Step 2: Created connection file db.php and paste below code to create database connection with mysql using PHP.

Step 3: Created HTML table list and pagination link.

Here we are creating a blank HTML table list, we will fill first time records using onInit method.

Step 4: Call simple Pagination methods on pagination container.

Here we are calling onInit method to fill first time records when page will load then after each time on click of pagination link we are calling onPageClick method and render rows of data into tbody of table.

Step 4: paginatioon.php file use to fetch records from database and bind with tr and return html to pagination ajax method.

You can download source code and Demo from below link.

Please feel free to send queries to me using below comment section.

  • what was error you are getting? its working fine .

    • side aly

      yes now it works the errors was with the file dist

  • vinod

    i am unable to get data from the table for two columns in pagination
    it is showing zero for columns.
    here i am pasting my code .



    Sample id


    Raw Bases

    Raw Reads

    • may be your sql query not correct,You have pasted HTMl where is php code.?

  • Prabu P

    please send the full source code

    • source code is attached with tuts, u can enable download link using social share button.

  • after doing the same thing three time (like,tweet and g+) fir bhi.. download button doesn’t appear.

    how Pathetic script you used bro.

    • I just tried using G+, it working fine.I am sending source code on your gmail id.

  • i am using ajax technology to get data from db using php whenever user ll click on page number.

  • Muahmmad Hasan

    Why my active page always 1?. It does not change when I click on other pages like 2 or 3

    • add the active class on page nav click, issue would be on nav jquery code

  • i am not able to get ur discussion topic, can u plz let us know what are you asking?

  • which is pagination plugin requirement

  • FoCoBiking

    Why did you use pagination.php?

    It looks like the same code is executed in the index.php file.

    Edit: Now I see. The AJAX in the jQuery needs the file 🙂


  • Venkatesh Gupta

    1. Well, I have set the limit as 5. On the first page; I see only 5 content but on the next page; I see all the 16 tupple of the database.

    2. And where are you calling Call simple Pagination methods on pagination container?

    • i think ur limit is resetting , hv u checked what is passing limit on second page using network tab in debugger