Pear Pear::P ager_php Tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    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.