我在CodeIgniter中工作。我想爲動態記錄創建分頁。所以我寫如下代碼:分頁不能在codeigniter中工作
$config = array();
$config["base_url"] = base_url() . "employer/search_user";
$config["per_page"] = 3;
$config['use_page_numbers'] = TRUE;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
if($this->uri->segment(3)){
$page = ($this->uri->segment(3)) ;
}
else{
$page = 1;
}
$query = "select sn.*,u.first_name,u.last_name,u.email,u.phone,group_concat(DISTINCT s.skill) as sk,group_concat(DISTINCT c.name) as ct from
users as u
left join snapshot as sn on sn.user_id = u.user_id
left join industry as ind on ind.ind_id = sn.industry
left join city c ON(FIND_IN_SET(c.city_id, sn.current_location) > 0)
left join skill s ON(FIND_IN_SET(s.skill_id, sn.skill) > 0)
where ".$where." u.group_id = 3 group by u.user_id limit ".$config["per_page"];
$data['users'] = $this->admin_model->query($query);
$row = count($data['users']);
$config["total_rows"] = $row;
$config['num_links'] = $row;
$this->pagination->initialize($config);
$data["links"] = $this->pagination->create_links();
$data['main_content']="employer/search_user";
$this->load->view('employer/template', $data);
在這裏,我有3個記錄在頁面但分頁鏈接不顯示。我在構造函數中包含分頁庫。我在$data["links"]
這個變量中沒有找到。
那麼,我必須糾正我的代碼?我的代碼有什麼問題?
$配置[ 「NUM_LINKS」]是將顯示分頁鏈接的數量。例如。 $ config ['num_links'] = 3然後 prev 1 2 3 next ,,,,如果它的4則prev 1 2 3 4 next – Calvin