Pagination with Jquery, PHP , Ajax and MySQL.

Friends, In my current employment i need to develop huge database driven web application. Which normally deals with millions  of records. I use indexing and cache techniques. Along with that i use jquery to make it handy for end use.


MySQL messages table contains two columns msg_id and message


JavaScript Code
The script works like a data controller.

Download the whole script from the download link above

paginate-all by

11 thoughts on “Pagination with Jquery, PHP , Ajax and MySQL.

  1. First at all, i have to say tat its a great way to paginate a query, thaks about that.

    I have a silly due, i want to put this pagination in a main page, until now everuthing perfect, but a how can a send a var from a menu item in order to filter the query.


    select * from table where filed=’$xxx’

    Thank you in advance

    1. Dear Capitan,

      1. The simplest trick is to call the loadData() function using jquery with an additional variable(which will hold your filter item)

      2. Pass it into the load_data.php page using the data variable of AJAX.

      3. Then in the load_data.php page, get it using the $_POST[‘qry’] and filter the database.

      Thanks for your query.

  2. Hello. I’m trying to use It With fancybox But there is no way, I use links with fancybox but I can’t do it work.

  3. Has anyone managed to get this working with a WHERE clause? For example:

    $query_pag_data = “SELECT * from products WHERE category_url=’$category_url’ LIMIT $start, $per_page”;

    1. Hola Pete.
      Lo que yo hice fue lo siguiente…

      En pagination.php envié la variable por url de la siguiente manera
      url: “load_data.php”,
      (donde palabra es la variable que recupero de un formulario)

      y en load_data.php la recuperé simplemente con con su nombre

      $query_pag_data = “SELECT * from ejemplo WHERE nombre=’$palabra’ LIMIT $start, $per_page”;
      (donde nombre es el campo de mi tabla mediante el cual quiero filtrar mis registros)

      $query_pag_num = “SELECT COUNT(*) AS count FROM ejemplo WHERE nombre=’$palabra'”;

      Ojalá te sirva. Saludos.

      ITSWADESH: Muchas gracias, un excelente desarrollo !

  4. sir! how can i implement this in my search engine i done it also in ajax, now i’m having trouble to implement this in my existing search engine….can you help me to work it out??
    thanks in advance….help is appreciated!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s