ページネーションの表示に少し問題があります。クエリが 1 つしかない場合でも、ページネーションが表示されます。欠けているのは$Pagesqueryの sql ステートメントであることを知って います。
これは私のコントローラーです
//This will only display local packages
public function displayLocalPackages($page=0,$offset=6,$search=''){
$search = $this->input->post('search');
$row = $this->m_tour->getAllLocalTours($offset,$page,$search);
$data['usersTable'] = $row->result();
$data['pagination'] = $this->m_tour->getLocTourPages();
$data['offset'] = $offset;
$data['page'] = $page;
$data['search'] = $search;
$data['title'] = 'Local Packages';
$this->load->view('vdisplaylocaltours',$data);
}
これは私のモデル関数です:
//will get the number of local pages
public function getLocTourPages(){
$Pagesquery = $this->db->get('tb_package');
$config['base_url'] = site_url('ctour/displayLocalPackages');
$config['total_rows']= $Pagesquery->num_rows();
$config['per_page'] = 6;
$config['first_link'] = 'First';
$config['prev_link'] = 'Previous';
$config['next_link'] = 'Next';
$config['last_link'] = 'Last';
$this->pagination->initialize($config);
return $this->pagination->create_links();
}
public function getAllLocalTours($offset,$count,$search){
#This will only occur if $search is NOT empty
if ($search!=''){
$this->db->where("(cat_id LIKE '%1%' AND pack_name LIKE '%$search%')");
$this->db->where('pack_status','available');
}
#cat_id corresponds with the local packages
$this->db->where('cat_id',1);
$this->db->where('pack_status','available');
$this->db->order_by('pack_name', 'desc');
$this->db->order_by('pack_id', 'desc');
#Query on the table package
$LocalQuery = $this->db->get('tb_package',$offset,$count);
if($LocalQuery->num_rows > 0){
return $LocalQuery;
}
else{
return FALSE;
}
}