Home Grown : 5. Pagination with PHP

This might not be that important topic from a web designer's point of view, but when we design an online system concerning data, the presentation of the data becomes very important. Usually the database contains hundreds of entries. And we would be hard pressed to write appropriate queries to retrieve the exact amount of data and to represent it as such. So here we take a look at a small solution that needs us to define What Data, How Much data per page & How to represent that data and then takes care of everything.

First lets create a database that will hold our hundreds of entries. Okay lets use mysql database (on your mysql server) itself. We'll create a page to paginate help_topic table. We'll use ps_pagination.php from PHPSense.
We have placed ps_paginate file in scripts. We include it in our PHP Page. After we create a connetion to database and fetch required data using a suitable query. Next we create a PS_Pagination object with the required parameters and recieve a Resultset for our page.
We represent this resultset into a table. Next to generate the links we call the render functions that PS_Pagination object supports. That's it.
This is Page No. 3 in the Example Project. So go through the code while I write a simple control to get you the GoTo page functionality. But that in next tutorial.

Download the Project from
HERE .

Comments

Popular posts from this blog

Morning Quotes

QCalendarWidget CSS Stylesheeting