1

我想做的是我想向用户展示这个

Showing 1 to  10 of 50 entries
Showing 11 to 20 of 50 entries
Showing 21 to 30 of 50 entries
Showing 31 to 40 of 50 entries
Showing 41 to 50 of 50 entries

我在我的应用程序中使用了 Zend Paginator 可以说

 Showing A to B of C entries

我可以很容易地找到 C 等于

 $result = $DB->fetchAll($sql);
 $total =count($result); 

如果我们在这里看到

 $page=$this->_getParam('page',1);
 //here we can get the requested page#.
 //lets hard code this
  $paginator->setItemCountPerPage(10);
  $per_page =10; 
  in my view   count($this->paginator)   give me total number of pages that is if
  if        total = 101     = $total
  than      page = 9        = $page
 and        paginator = 11  = count($this->paginator)

我怎样才能做到这一点,但通用的意思是使用下一个,上一个等等..

4

1 回答 1

1

显示 C 条目的 A 到 B

大致是这样的:

$page = $paginator->getCurrentPageNumber();
$perPage = $paginator->getItemCountPerPage();
$total = $paginator->getTotalItemCount();

$A = ($page - 1) * $perPage + 1;
$B = min($A + $perPage - 1, $total);
$C = $total;
于 2012-01-31T14:24:03.587 回答