Pear of pear::P ager

Source: Internet
Author: User
Tags pear

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 ().: ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.