Simple Ajax Pagination with PHP

In previous tutorial we have learn Simple tutorial of pagination in php, here we will learn php pagination with days we are using ajax functionality for each request.We are using jQuery library for Ajax request and MySQL for database.

We have following files:
1- db.php : This file contains db connection information.
2- pagination.php : this file return html table as a response.
3- index.php :This file is used as a requester.

Checkout other tutorials of pagination,

To create Ajax pagination we need to follow below steps:

Step 1:Create db.php and put below connection code in this file.

Step 2:Created index.php file and putted below code into this file.

Step 3:Created pagination.php and putted below code into this file.

Result :


you can check live domo and download source code from below link,

  • Subhendu Roy

    Where is db.php

    • in downloaded zip file, there is posts.sql and dp.php file

  • Subhendu Roy

    Can you give the database in .sql format.

  • Muneesh Pandi

    Hi, very useful tutorial.. this jquery load function was not working on server..but its working perfect on local server only .. can u say any other solution? thanks in advance

    • what was error you are getting on server?

      • Muneesh Pandi

        Hi, now its working using urs Advanced AJAX Pagination with PHP and Mysql script. if i use where condition on pagination page, it doesn’t work. i don’t know, how to pass table id?… can u help me..
        @ pagination page:- $sql = “select * from review where advertiserid=’$aid’ order by reviewid desc LIMIT $start_from, $limit”;

      • Muneesh Pandi

        Hi, i solved this problem, now its working perfect. i had added table id into script
        jQuery(“#target-content”).load(“pagination.php?aid=&page=” + pageNumber );
        can u say?.. this pagination have prev & next button only, how can i show the first & last button?

        i had tried in php but its doesn’t show these buttons

        • You can add these buttons using PHP logic

          • Muneesh Pandi

            Ok thanks for ur response.. i will try these buttons in php.

            one more request, can u post remote method to check username availabilty? Thanks in advance.

          • Thanks muneesh, i will post soon.

          • Muneesh Pandi

            Thank u so much!

  • shree

    I want two id pass on next page, How can i do this ?

  • have u connected mysql db and using right table.Please send code if still getting error on ll try my best to solve ur issue.

  • can pls recheck db name

    • Mukesh Thavrani

      This is the code i use to connect the database
      $dbname = ‘test’;

      • looking good so i need to test code,can u plz send code on phpflow gmail.