This is a small tutorial about How to make a pagination whit Zend Paginator
so we a have an action let say listAction
public function listAction()
{
$sql = ‘SELECT * FROM table’;
$result = $db->fetchAll($sql);
$paginator = Zend_Paginator::factory($result);
$paginator->setCurrentPageNumber($this->_getParam(‘page’));
$paginator->setItemCountPerPage(10); //where 10 is the number of records per page
$this->view->paginator = $paginator;
$this->view->page_nr = $this->_getParam(‘page’);
$this->render(‘list’);
}
now let see the design list.phtml
<div>
<table>
<tr>
<td>Col1</td>
<td>Col2</td>
<td>Col3</td>
<td>Col4</td>
</tr>
<?php
foreach($this->paginator as $row): ?>
<tr>
<td><?= $this->escape($row['col1']) [...]
Posts Tagged ‘Zend Paginator’
Zend Paginator Example
Posted by Victor on January 25th, 2009



Posted in
Tags: