Home >Backend Development >PHP Tutorial >PEAR Exploration PEAR::Pager_PHP Tutorial

PEAR Exploration PEAR::Pager_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:58:57832browse

Displaying a large amount of data on a page is a very common practice in WEB projects. However, due to the size of the screen, in order to facilitate user reading, we usually need to display the data in pages, so the paging function is used in most projects. Indispensable. PEAR::Pager is a powerful paging class that is very convenient to use.

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

PEAR::Pager has two paging display modes, one is Jumping and the other is 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 items displayed per page:".$params['perPage'];
echo "
Display 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 of the current page: ' ;
echo "

";<br>
print_r($data);<br>
echo "
";

echo "Data obtained by other 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().: ';

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631975.htmlTechArticleDisplaying a large amount of data on the page is a very common practice in WEB projects, but it is limited to the size of the screen. To make it easier for users to read, we usually need to display the data in pages, so paging...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn