Re: initial pageID set in pager
| From: | Lorenzo Alberton | Date: | Tue, 11 Jan 2005 20:17:30 +0000 |
| Subject: | Re: initial pageID set in pager | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16879@lists.php.net to get a copy of this message | ||
Leo Márquez wrote:
Hi!, There is a way to define witch page starts displaying a Pager object? I have a pagination of invoices and want to list in ascend order but the first page displayed (first time the page is open) must be the last page. I'have tried it passing the $pager->numPages() value to this methods: $pager->getPerPageSelectBox($pager->numPages()) $pager->getLinks($pager->numPages()) but I don't know how to control this when the user change the page. Always is showed the same page, the last.there are a number of ways to do it. The simplest one probably is adding these lines at the top of the script: $totalItems = XXX; //count the items to be paged $perPage = 30; if (!isset($_GET['pageID'])) {
$_GET['pageID'] = ceil((float)$totalItems / (float)$perPage);} otherwise, you can control the page # explicitly: $pager->getLinks($pageID); $pager->getPageData($pageID); HTH -- Lorenzo Alberton http://pear.php.net/user/quipo