[eluser]zsela[/eluser]
Hi everybody!
I ran into a strange problem during paginating a page. This is the first time I do this with CI, so probably it is just a small inadvertence.
The links created by CI are not growing one at a time, but growing by 2, 3 or whatever the per_page value is. For example if $config[per_page] = 3, then the links are like these:
../list_users/3
../list_users/6
Here is the code, from the controller:
Code:
// pagination
$this->load->library('pagination');
$config['base_url'] = base_url() .'index.php/admin/list_users/';
$config['per_page'] = 3; // találatok száma oldalanként
$config['num_links'] = 2;
$config['first_link'] = '<<';
$config['last_link'] = '>>';
$page = $this->uri->segment(3); // oldal index
$count_user = $this->Admin_model->get_all_users_num();
$all_user = $this->Admin_model->get_users($page, $config['per_page']);
$config['total_rows'] = $count_user;
$this->pagination->initialize($config);
$this->load->view('admin/manage_users', array('all_user' => $all_user, 'count_user' => $count_user, 'config' => $config, 'page' => $page));
And from the view:
Code:
$lThr = $page * $config['per_page'] + 1;
if (($page + 1) * $config['per_page'] >= $config['total_rows']) $uThr = $config['total_rows'];
else $uThr = ($page + 1) * $config['per_page'];
echo '<p class="twelve">Oldalak: ';
echo $this->pagination->create_links();
echo '</p>';
echo '<p class="right">';
echo 'Találatok: ' . $lThr . ' - ' . $uThr . ' / ' . $config['total_rows'];
echo '</p>';
Thanks for your answers in advance!