|
怎么点第一页的连接不是到第一页,而是到第2页了呀
还有首页连接,也不是首页,而是当前页
是怎么回事?
$config= array();
$config['per_page'] = 2; //每页显示的数据数
//print_r($_GET);
$current_page = intval($this->input->get_post('per_page',true)); //获取当前分页页码数
//page还原
if(0 == $current_page)
{
$current_page = 1;
}
$offset = ($current_page - 1 ) * $config['per_page']; //设置偏移量 限定 数据查询 起始位置(从 $offset 条开始)
$result = $this->home_model->liebiao($offset,$config['per_page'],$order='id desc');
$config['base_url'] = '';
$config['first_link'] = 'First';;//首页
$config['prev_link'] = '上一页<';//上一页
$config['next_link'] = '下一页>';//下一页
$config['last_link'] = '尾页';//尾页
$config['num_tag_open'] = ' ';
$config['num_tag_close'] = ' ';
$config['total_rows'] = $result['total'];//总条数
$config['num_links'] = 3;//页码连接数
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = TRUE;
$this->load->library('pagination');//加载ci pagination类
$this->pagination->initialize($config);
$result = array(
'list' => $result['list'],
'total' => $result['total'],
'current_page' => $current_page,
'per_page' => $config['per_page'],
'page' => $this->pagination->create_links(),
);
|
|