HTTPS SSH

Pagination PHP Class

pagination is a php class for long lists pagination and easy navigation.

2013-12-03 UPDATE: Added README

Usage

Pagination is used on displaying long lists of data. Lists are split into small parts. There is built a easy to navigate menu between these parts. Several pages, 5 by deafult, form a group of pages. Pagination menu permits navigation between pages of the same group, between groups and to start or end of list.

Class methods display list navigation menu. Pulling data from data storage and displaying data is totally on class user side and is based on pagination GET variable $_GET['pag'].

Methods

  • "pagebar": returns the navigation menu
  • "randlist": creates a random list for test purposes

Propreties

  • "$valcount": Total number of list items (defaults to 0)
  • "$perpage": Number of items displayed per page (defaults to 10)
  • "$curpage": Current page (defaults to 1)
  • "$pagesblock": Number of navigation bar pages displayed simultaneously

Compatibility

  • PHP 4.XX, 5.XX

Examples

This generic example shows how to build pagination menu. Generates a random list.

//include pagination class

include_once("pagination.class.php");

$pag = new Pagination;

//setup the default values

$pag->valcount = 168; //number of values to paginate

$pag->perpage = 10; //values per page

$pag->curpage = isset($_GET['pag']) ? $_GET['pag'] : 1; //get current page id

$pag->pagesblock = 10; //number of pages visible simultaneously

//generate a random list

$pag->randlist();

//return navigation bar

$navbar = $pag->pagebar();

echo $navbar;

ToDo

  • new method: pull data out of database by: tablename, tablefields (array), based on page ID. Return Array
  • new method: pull out data from file. Return Array
  • read and correct: class description and usage

Enjoy!