[英]CodeIgniter Pagination Last Page Issue
I have been searching solution for my problem but i can't find an answer to it. 我一直在寻找我的问题的解决方案,但我找不到答案。 My problem i believe is different than what normally others will be facing with codeigniter's pagination library.
我认为我的问题与其他人通常会使用codeigniter的分页库所面临的问题不同。
I have 15 records inside my database and i wanna display 5 each page with the pagination. 我的数据库中有15条记录,我希望每页显示5个分页。 below is my pagination config :
下面是我的分页配置:
$config["base_url"] = base_url() . "main";
$config["total_rows"] = $total_row[0]['total'];
$config["per_page"] = 5;
$config["uri_segment"] = $this->uri->segment(2);
$config['num_links'] = 2;
$config['use_page_numbers'] = TRUE;
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$this->pagination->initialize($config);
now the pagination display like this : 现在分页显示如下:
1 2 3 > 1 2 3>
and if i navigate to page 2 my URL will be http://blablabla.com/blablabla/2
and the data loaded correctly also the pagination will be 如果我导航到第2页,我的网址将是
http://blablabla.com/blablabla/2
并且正确加载的数据也将是分页
< 1 2 3 > <1 2 3>
but if i go to the last page, the URL will be http://blablabla.com/blablabla/3
which is fine, the data loaded also correct but the pagination will be 但如果我转到最后一页,URL将是
http://blablabla.com/blablabla/3
这很好,加载的数据也正确但分页将是
1 2 3 > 1 2 3>
when i go to last page, the first page link will be highlighted. 当我转到最后一页时,第一页链接将突出显示。 Is there any problem with my config?
我的配置有问题吗?
I think you need to change : 我想你需要改变:
$config["uri_segment"] = $this->uri->segment(2);
to 至
$config["uri_segment"] = 2;
because you just need to mention uri-segment numer here, if you put like this $this->uri->segment(2) system will take value at segment 2 as $config["uri_segment"] and if that segment is not exist it will highlight first page as current page. 因为你只需要在这里提到uri-segment numer,如果你像这样放这个$ this-> uri-> segment(2)系统将在第2段取值为$ config [“uri_segment”]并且如果该段不存在它将突出显示第一页作为当前页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.