Simple tutorial of pagination in php

In this PHP tutorial We will learn how to create simple pagination in PHP. The pagination can be ajax based but here i am creating pagination with non ajax.In this tutorial I am using bootstrap3 and PHP5.I am assuming you have table and data.

I am following below simple steps:

Step 1: I am connecting database with table.
Step 2: I am filling selected data into tables.
Step 3: I am creating pagination link and added bottom of table.

Checkout other tutorials of pagination,

The below source code help you to create pagination in PHP. Its very simple code to generate pagination with help of bootstrap.


pagination in php

you can check live demo and download source code

  • Proxenix

    I’ve tried some scripts to make the active state on navigation, but with no success. Can you provide me some directions for how to generate the active state nav on active page? Thanks.

    • Ya sure,
      You can use jQuery live event on nav link like below:
      $(‘.navlink’).live(‘click’, function({


      This code fired on your navigation links which has ‘navlink’ class.We first remove active class and then add active class on current clicked navigation.
      I hope its help.

  • adminawala

    not work dude..

  • Nehara

    tnx dude! it’s wrkng perfectly!

  • thank…

    dwi from Indonesia

  • Dileep Kumar


  • Chintan Panchal

    thank you so much man you have saved my time. you have done job without any jquery or ajax plugins.

    • Nurwani Enn

      Do you know why I get ‘SQL error’?

      • can u plz post full error which r u getting

  • Ido N

    Thanks for this useful code!
    What if I’ve hundreds of pages?
    Any way to shrink it to few pages and “next” and “previous” buttons?

    • you can apply same method but on anchor link set ur pages url

  • Gautam

    Thx man works perfect!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Pulkit Kashyap

    this is awesome, thanks man

  • Santosh Lourembam

    $pagLink = “”;

    can any1 please explain this line where this class is written

    • this line will create pagination main div