This class generates the html for navigation links for listings spread out over different pages.
This is usefull for displaying large amounts of records from a Mysql query but can also be used for other purposes.
It has the following features:
The sql results must have at least one field and a field that contains an unique identifier (UID)
Included files:
example.php - example of the use of this class (change the settings for mysql access as appropriate)
example.sql - example table for use with example.php
pagecreator.php - class with helper functions
Readme.html - this file
Released under GNU public license
Direct all comments to Tony 'Grefix' David
Create_PageLinks | ||
---|---|---|
creates the pagelinks in html. | ||
check_variables | ||
checks all nescessarry variables and sets them to default
if they don't meet the requirements. Also displays a message if variables that need to be given by the user script aren't set |
Create an instance of the class
Set the variables
$pg->TotalItems=100; |
---|
!! this one needs to be set by the user !! It's the amount of items that will be shown over all the pages (eg: total of resulting records from a mysql_query) |
$pg->ItemsPerPage=50; |
Amount of items that will be shown per page (eg: part of the result of
a mysql_query) defaults to 10 |
$pg->PrevNext=true; |
display a Previous/Next link default is true (possible values true, false) |
$pg->FirstLast=true; |
display a First/Last pagelink default is true (possible values true, false) |
$pg->TrailingPages=2; |
The amount of numbered page links that will be shown before and after the current page. example: 2 will generate 5 pages, 2 before, the current page and 2 after default is 2 |
$pg->UsePoints=true |
Display points before and after the pagelinks if there are more pages
than the ones shown: (eg: First Prev.. 8 9 10 11 12 .. Next Last) default is true | $pg->Points='..' |
string that will be used to represent the points default is: .. |
$pg->ShowTotalPages=true |
Display the total of all pages before the pagelinks(default true) |
$pg->ShowTotalPages="Pages:" |
$pg->ScriptVariable="st"; |
the parameter that will is used in the url to set the number of the first item in a page default is st |
$pg->ScriptFile=""; |
the url of the script (without parameters) defaults to the current url (PHP_SELF) |
$pg->Parameters=" " |
an array with parameters and their values you possibly want to be used to for other reasons example: $pg->Parametes=array('act'=>'list','sort_field'=>'id') |
Send questions to Tony 'Grefix' David
website: http://grefix.buildtolearn.com
demonstration of the example can be found at http://grefix.buildtolearn.com/php/classes/pagecreator/example.php