PEAR: Pager

Source: Internet
Author: User
Displaying a large amount of data on a page is a common practice in WEB projects, but limited by the size of the screen, we usually need to display the data by Page to make it easier for users to browse, therefore, the paging effect is indispensable for most projects. PEAR: Pager is

Displaying a large amount of data on a page is a common practice in WEB projects, but limited by the size of the screen, we usually need to display the data by Page to make it easier for users to browse, therefore, the paging effect is indispensable for most projects. PEAR: Pager is a powerful paging class with very convenient applications.


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


PEAR: Pager has two paging display modes: Jumping and Sliding. What is the difference 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 ')
);

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


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


Echo'

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

Echo'

Data on the current page :';
Echo'

'; 
print_r($data);
echo '
';

Echo 'data obtained by other class methods:

';
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 ().:';
Var_dump ($ pager-> isLastPageComplete ());
Echo'
';
Echo '$ pager-> range ........:';
Var_dump ($ pager-> range); echo'
';

?>


The running result is as follows:


Sliding. php

 

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.