在 zend Paginator 中添加(显示当前开始到总条目数)

发布于 2025-01-01 00:52:40 字数 866 浏览 1 评论 0原文

我想做的是,我想向用户展示我

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)

我如何实现这一点,但通用意味着与下一个、上一个等一起工作在..

what i want to do is that i wana show user this

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

i have used Zend Paginator in my app lets say

 Showing A to B of C entries

I can easily find C which is equal to

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

if we see here

 $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)

how can i achieve this but generic mean working with next,previous and so on..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红衣飘飘貌似仙 2025-01-08 00:52:40

显示 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;

Showing A to B of C entries

Is roughly this:

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

$A = ($page - 1) * $perPage + 1;
$B = min($A + $perPage - 1, $total);
$C = $total;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文