Displaying a large amount of data on a page is a common practice in Web projects, but is limited to the size of the screen, and in order to make it easier for users to read, we often need to display the data in pagination, so paging is an essential part of the project. PEAR::P Ager is a powerful paging class that is very convenient to use.
System requirements: php4.3.*/php5,pear::P ager
PEAR::P ager have two kinds of paging display mode, one is jumping, the other is sliding. What's the difference between the two, let's take a look at two examples:
jumping.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 "
Current paging mode: ". $params [' mode '];
echo "
Number of data bars per page: ". $params [' perpage '];
echo "
Show Pages: ". $params [' Delta '];
echo "
Specific data array: ";
Print_r ($params [' ItemData ']);
$pager = & Pager::factory ($params);
$data = $pager->getpagedata ();
$links = $pager->getlinks ();
echo "
Final effect: ";
echo $links [' all '];
Echo $pager->linktags;
Echo '
Data for the current page: ';
echo "
";
Print_r ($data);
echo "
";
echo "Other class methods get the data:
";
Echo ' Getcurrentpageid () ...: ';
Var_dump ($pager->getcurrentpageid ());
echo "
";
Echo ' Getnextpageid () ...: ';
Var_dump ($pager->getnextpageid ());
echo "
";
Echo ' Getpreviouspageid ().: ';
Var_dump ($pager->getpreviouspageid ());
echo "
";
Echo ' NumItems () .....: ';
Var_dump ($pager->numitems ());
echo "
";
Echo ' NumPages () .....: ';
Var_dump ($pager->numpages ());
echo "
";
Echo ' Isfirstpage () ...: ';
Var_dump ($pager->isfirstpage ());
echo "
";
Echo ' Islastpage () ...: ';
Var_dump ($pager->islastpage ());
echo "
";
Echo ' Islastpagecomplete ().: ';
http://www.bkjia.com/PHPjc/631975.html www.bkjia.com true http://www.bkjia.com/PHPjc/631975.html techarticle displaying a large amount of data on a page is a common practice in Web projects, but is limited to the size of the screen, and in order to make it easier for users to read, we usually need to display the data in pagination, so pagination ...