Page 1 of 1

Generic paging class

Posted: Sun Sep 25, 2005 10:20 pm
by PCSpectraRetired
I HATE writing code for pagination of records and having to keep track of the page index, number of items to display, etc...so I have considered trying to invent some generic paging class to assist in the madness...

I have looked at all the PHP Paging classes out there (from what could be easily found via Google anyways) and none really appeal to me. There either tied to a specific database like MySQL or require to much tinkering and tweaking to get working.

So my question then is:

Has anyone ever used a PHP Paging class which just dropped into their code and was ready to go? Can I have the link so as to steal ideas from a existing solid class or use it directly if it's good enough.

What I have considered thus far is a class which uses a callback to fill an array from whatever data source desired.

- RDBMS
- Flat file
- XML
- LDAP, etc...

Of course this creates problems onto it's own, cuz now you need a callback to get the total number of records, etc...

Anyways, just an idea I figured I'd blow by you guys and see what I could back as far as feedback :)

Cheers :)

Posted: Mon Sep 26, 2005 2:22 am
by n00b Saibot
I have written one such function that is inspired by that WROX book :arrow: PHP & MySQL - Problem Design Solution or something like that. It takes two params- an array of record to displayed on that page and total no. of records. the no. of records to be displayed is controlled by a global var.

HIH :wink: