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 ')
);

Echo"
Current paging mode: ". $ params ['mode'];
Echo"
Number of data entries per page: ". $ params ['perpage'];
Echo"
Displayed page number: ". $ 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 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 ().:';

...

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.