Introduction: This is pear's pear: detailed page of pager. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 324385 'rolling = 'no'>
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, 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
<? 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> Number of data entries per page:". $ Params ['perpage'];
Echo "<br> display page number:". $ Params ['delta'];
Echo "<br> detailed data array :";
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> data on the current page :';
Echo "<PRE> ";
Print_r ($ data );
Echo "</PRE> ";
Echo "data obtained by other methods: <p> ";
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 ().:';
Var_dump ($ pager-> islastpagecomplete ());
Echo "<br> ";
Echo '$ pager-> range ........:';
Var_dump ($ pager-> range); echo "<br> ";
?>
The running result is as follows:
Sliding. php
<? PHP
Require_once 'pager/pager. php ';
$ Month = 'September ';
$ Params = array (
'Mode' => 'sliding ',
'Append' => false,
'Urlvar '=> 'num ',
'Path' => 'HTTP: // localhost/'. $ month,
'Filename' => 'art+d.html ', // % d will be replaced with the number on the current page
'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 '),
'Perpage' => 3
);
Echo "<br> current paging mode:". $ Params ['Mode'];
Echo "<br> Number of data entries per page:". $ Params ['perpage'];
Echo "<br> link to path:". $ Params ['path'];
Echo "<br> link to file name:". $ Params ['filename'];
Echo "<br> detailed data array :";
Print_r ($ Params ['itemdata']);
$ Pager = & Pager: Factory ($ Params );
$ DATA = $ pager-> getpagedata ();
Echo "<p> final effect :";
Echo $ pager-> links;
Echo '<p> data on the current page :';
Echo "<PRE> ";
Echo 'data for current page: '; print_r ($ data );
Echo "</PRE> ";
Echo "data obtained by other methods: <p> ";
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 ().:';
Var_dump ($ pager-> islastpagecomplete ());
Echo "<br> ";
Echo '$ pager-> range ........:';
Var_dump ($ pager-> range); echo "<br> ";
?>
The running result is as follows:
RunCode, We can see that jumping is a jump, a few pages at a time, and sliding is a page-by-page forward.
In the example, we can see that pear: pager provides many class methods to return the data we need, such as the ID of the current page, the ID of the next page, and the number of data entries on the current page.
The functions of all class methods are listed as follows:
Pager: Pager (). If the constructor parameter is a two-dimensional array, see the preceding example.
Pager: Factory () -- creates a pager object
Pager: getcurrentpageid () returns the ID of the current page
Pager: getlinks () returns the Link parameter corresponding to a page. If the page ID parameter is null, the link of the current page is returned.
Pager: getnextpageid () returns the ID of the next page
Pager: getoffsetbypageid () return record range
For example, if the current page is 1 and 10 entries are displayed on each page, the system returns)
If the current page is 2 and 8 entries are displayed on each page, the system returns (8, 16)
Pager: getpagedata () returns the current page data in array form
Pager: getpageidbyoffset () returns the page id based on the record range
This method is only valid when the paging mode is jumping.
Pager: getpagerangebypageid () returns the record range of a page
For example, if the mode is jumping, if pageid = 3, Delta = 10, return (). If pageid = 3, Delta = 10, return ), because 1 and 3 are within the range of 10. If pageid = 14, return ),
Because 14 falls between 10 and 20.
Pager: getpreviouspageid () to get the ID of the previous page
Pager: getperpageselectbox () Returns An XHTML select tag string
Can be used to directly jump to a page
Pager: isfirstpage () determines whether the current page is the first page
Pager: islastpage () determines whether the current page is the last one
Pager: islastpagecomplete () determines whether the last page is reached
Pager: numitems () Total number of returned records
Pager: numpages () Total number of returned pages
For other functions and usage, see pear: Pager:
More articles about pear: Pager
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/324385.html pageno: 15.