我用codeigniter的分页....但主要问题是页码不正确显示。Codeigniter页码正确显示?
在控制器我使用以下代码:
$count = $this->db->count_all_results('table');
$this->load->library('pagination');
$this->load->library('pagination');
$config['base_url'] = base_url().'/lists/';
$config['total_rows'] = $count;
$config['per_page'] = 2;
$config['uri_segment'] = $this->uri->segment('2');
$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);
if($config['uri_segment']<=0) $offset = 0;
else $offset = ($config['uri_segment'] - 1)* 2;
$limit = 2;
$data['infoArr'] = $this->home_model->get_all($offset, $limit);
$this->load->view('list_info',$data);
在模型我用下面的代码:
function get_all($offset, $limit){
return $this->db->query("SELECT * FROM table ORDER BY id DESC LIMIT $offset,$limit")->result_array();
}
并鉴于我使用
<?php echo $this->pagination->create_links(); ?>
在我的表9的信息是插入... 根据数据库分页1 2 3 4 5应显示,但仅显示1 2 3>最后显示。
,当我在2单击显示只有4号,否则4,不显示5号... 什么代码中的主要问题是.... 请帮助我..提前
谢谢所有谁帮我..
感谢您的帮助,但下一步按钮不起作用well..it适用于页码1和2然后页码3它的显示页面1 ... 。 –
确保你的'$ config ['total_rows']'是正确的,并且考虑如果需要的话扩展和改变分页库。 –
总行数是正确的,页面显示数量是正确的,但下一个按钮和上一个按钮不能正常工作..... –