This is a basic script to take an array and and generate a paginated list of items. This is quite an obscure example because a real world example would probably include lots more data.
I'd also like to say, if your working with databases then I would suggest using a database pagination script that uses limits etc to optimise the speed of the query etc. If your looking to paginate a small data set then this should be fine.
Pretty simple setup:
Include the class:
Here i'm throwing in some test date (you will need to provide your own)
Then this is how to output of the page data and page numbers.
There are two other configurations that currently exist:
If you would like to show "<< first" and "last >>" links to take you to the first and last page.
The default separator for the page numbers is an empty string, you can overwrite this to be anything you like.
It's pretty simple.
Download Complete Script in Zip from here: https://app.box.com/s/8an37ogzo915p3rnz3ej
This article Taken from: http://lotsofcode.com/php-array-pagination/
No comments:
Post a Comment
Please Comment Here!