如果我点击下一个数字链接,我的视图有分页,它工作正常。比如:
1 2 >
因此,如果我单击 2,它将进入第二页并显示正确的结果。但现在如果我想返回 1,而不是重定向我。即使有链接 3,我也无法访问 2。
这是我的代码:
控制器:
function list_providers()
{
$admin_session_data= $this->session->userdata('user_logged_in');
$this->load->model('/admin/provider_model');
$this->load->library('pagination');
$this->load->helper('url');
$config['base_url'] = base_url()."index.php/admin/provider/list_providers/";
$config['total_rows'] = $this->provider_model->countprovider();
$config['per_page'] = 3;
$config['creat_link'] = 1;
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$this->pagination->initialize($config);
$offset=($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data['list']= $this->provider_model->listproviders($config['per_page'],$offset);
//$data['customer']= $this->provider_model->getcustomer_data($config['per_page'],$this->uri->segment(3));
if(!empty($data))
{
$this->load->view('admin/admin_header',$admin_session_data);
$this->load->view('admin/admin_top_nav',$admin_session_data);
$this->load->view('admin/admin_left',$admin_session_data);
$this->load->view('admin/provider_list',$data);
$this->load->view('admin/admin_footer',$admin_session_data);
}
}
模型:
function listproviders($num,$offset)
{
$this->load->library('pagination');
//$query=$this->db->get_where('users', array('user_role_id'=>'3'));
$query=$this->db->get('users',$num,$offset);
// return result set as an associative array
return $query->result_array();
}
function countprovider()
{
$this->load->library('pagination');
$query=$this->db->count_all_results('users');
return $query;
}
我的分页显示如下: 1 2 >
请看问题出在哪里。