开发者

Pagination in codeigniter

Help me my url in pagination ! :(

$data['total'] = $this->news_model->all_list();
$this->load->library('pagination');
$config['base_url'] = site_url().'admin/news/page';
$config['total_rows'] = count($data['total']);
$config['per_page'] = '5';
$this->pagination->initialize($config);
$data['columns'] = array('Tile', 'Date', 'User', 'Active', 'Edit', 'Delete');
$data['list'] = $this->tintuc_model->all_list($config['per_page'],$this->uri->segment(3));

    $data['pagination'] = $this->pagination->create_links();

    $this->smarty->view( 'admin/news.tpl', $data );

That's my code. List of pages showed ok. But, when all links are wrong.

eg: when i click the 2 page link => http://localhost/mysite/admin/news/page/5 ?

Why it开发者_开发知识库 is 5 instead of 2 ?


you can change

$config['per_page'] = '5';

to

$config['per page'] = '2';

in order to get 2 in your uri segment, but it indicates the limit of data to be displayed in your page not the clicked pagination number.


It's not the page number - it's page number * items per page

In your case $config['per_page'] = '5'; So everything seems to be okay.


You need to set:

$config['use_page_numbers'] = TRUE;

http://ellislab.com/codeigniter/user-guide/libraries/pagination.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜