Displaying a large amount of data on a page is a common practice in Web projects, but limited to the size of the screen, we usually need to display the data paging to make it easier for users to read, so paging is an essential part of the project. PEAR::P Ager is a powerful paging class that is very handy to use.
System requirements: php4.3.*/php5,pear::P ager
PEAR::P Ager has two pagination display modes, one is jumping, the other is sliding. What is the difference between the two, let's look at two examples:
jumping.php
<?php
Require_once ' pager/pager.php ';
$params = Array (
' Mode ' => ' jumping ',
' Perpage ' => 3,
' Delta ' => 5,
' ItemData ' => Array (' A ', ' B ', ' C ', ' d ', ' e ', ' Z ', ' ty ', ' xc ', ' FG ', ' FG ', ' JK ', ' HJ ', ' Ty ', ' xc ', ' e ', ' Z ', ' ty ', ' xc ', ' FG ', ' FG ', ' JK ', ' HJ ', ' Ty ', ' XC '
);
echo "<BR> Current paging mode:". $params [' mode '];
echo <BR> display Data bar per page: ". $params [' perpage '];
echo "<BR> Show Pages:". $params [' Delta '];
echo "<BR> array of specific data:";
Print_r ($params [' ItemData ']);
$pager = & Pager::factory ($params);
$data = $pager->getpagedata ();
$links = $pager->getlinks ();
echo "<P> final effect:";
echo $links [' all '];
Echo $pager->linktags;
Echo ' <P> current page data: ';
echo "<pre>";
Print_r ($data);
echo "</pre>";
echo "Data:<p> from other classes of methods";
Echo ' Getcurrentpageid () ...: ';
Var_dump ($pager->getcurrentpageid ());
echo "<BR>";
Echo ' Getnextpageid () ...: ';
Var_dump ($pager->getnextpageid ());
echo "<BR>";
Echo ' Getpreviouspageid ()..: ';
Var_dump ($pager->getpreviouspageid ());
echo "<BR>";
Echo ' NumItems () .....: ';
Var_dump ($pager->numitems ());
echo "<BR>";
Echo ' NumPages () .....: ';
Var_dump ($pager->numpages ());
echo "<BR>";
Echo ' Isfirstpage () ...: ';
Var_dump ($pager->isfirstpage ());
echo "<BR>";
Echo ' Islastpage () ...: ';
Var_dump ($pager->islastpage ());
echo "<BR>";
Echo ' Islastpagecomplete ().: ';