PEAR: Pager_PHP tutorial

Source: Internet
Author: User
PEAR: Pager. Displaying a large amount of data on a page is a common practice in WEB projects, but limited by the size of the screen, in order to facilitate user reading, we usually need to display the data by page, therefore, it is common for WEB projects to display a large amount of data on pages by page. however, to make the screen size easier for users to read, we usually need to display the data by page, therefore, the paging function is indispensable for most projects. PEAR: Pager is a powerful paging class, which is very convenient to use.

System requirements: PHP4.3. */PHP5, PEAR: Pager

PEAR: Pager has two paging display modes: Jumping and Sliding. What are the differences between the two? let's 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 ')

Current paging mode: ". $ params ['mode'];
Number of data entries per page: ". $ params ['perpage'];
Displayed page number: ". $ params ['Delta'];
Specific data array :";
Print_r ($ params ['itemdata']);

$ Pager = & Pager: factory ($ params );
$ Data = $ pager-> getPageData ();
$ Links = $ pager-> getLinks ();


Final effect :";
Echo $ links ['all'];
Echo $ pager-> linkTags;


Data on the current page :';

echo "

Echo "data obtained by other class methods:

Echo 'getcurrentpageid ()...:';
Var_dump ($ pager-> getCurrentPageID ());
Echo 'getnextpageid ()......:';
Var_dump ($ pager-> getNextPageID ());
Echo 'getpreviouspageid ()..:';
Var_dump ($ pager-> getPreviousPageID ());
Echo 'numitems ()...........:';
Var_dump ($ pager-> numItems ());
Echo 'numpages ()...........:';
Var_dump ($ pager-> numPages ());
Echo 'isfirstpage ()........:';
Var_dump ($ pager-> isFirstPage ());
Echo 'islastpage ().........:';
Var_dump ($ pager-> isLastPage ());
Echo 'islastpagecomplete ().:';


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: 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.