O'Reilly logo

PHP Ajax Cookbook by R. Rajesh Jeba Anbiah, Roshan Bhattarai, Milan Sedliak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building Pagination using PHP and Ajax

In this task, we will learn how to build pagination with Ajax functionality. That means we will be able to turn the page in the contact list without reloading the whole website.

How to do it...

  1. We will start with HTML, which contains the page container, contact grid with the first displayed page of contacts, and the contact pagination:
    <div id="pageContainer"> <div id="contactGrid"> <div class="contact"> <img src="images/avatar.png" alt="avatar" /> <h2>Milan Sedliak</h2> <p>Prague, Czech Republic</p> </div> <!-- // add more contacts --> <div class="contact"> <img src="images/avatar.png" alt="avatar" /> <h2>Milan Sedliak (home)</h2> <p>Malacky, Slovakia</p> </div> </div> <ul id="contactPagination"> <li><a href="#previous" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required