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 に答える