2016-12-08 106 views
0

我做的代碼點火器分頁,加入的搜索目的的兩個表分頁代碼點火器

我的模型的

public function main_search_count($term) 
 
    { 
 
if ($term == "NIL") $term = ""; 
 
$this->db->select('*');  
 
$this->db->from('tbl_doctor'); 
 
$this->db->join("tbl_specialisation", "tbl_specialisation.spec_id = tbl_doctor.spec_id",'left'); 
 
$this->db->where("(tbl_doctor.dr_name LIKE '%".$term."%' OR tbl_doctor.district LIKE '%".$term."%' OR tbl_specialisation.spec_specialise LIKE '%".$term."%')"); 
 
$query= $this->db->get(); 
 
return $query->num_rows(); 
 
    } 
 
    public function fetch_data($limit, $offset, $term) 
 
    { 
 
if ($term == "NIL") $term = ""; 
 
$this->db->select('*');  
 
$this->db->from('tbl_doctor'); 
 
$this->db->join("tbl_specialisation", "tbl_specialisation.spec_id =   tbl_doctor.spec_id",'left'); 
 
$this->db->where("(tbl_doctor.dr_name LIKE '%".$term."%' OR tbl_doctor.district LIKE '%".$term."%' OR tbl_specialisation.spec_specialise LIKE '%".$term."%')"); 
 
$this->db->limit($limit, $offset); 
 
$query = $this->db->get(); 
 
if($query->num_rows()>0) 
 
{ 
 
return $query; 
 
} 
 
}
我控制器

function get_quick_doct($offset = 0) 
 
    { 
 
$term = ($this->input->post("term"))? $this->input->post("term") : "NIL"; 
 
$term = ($this->uri->segment(3)) ? $this->uri->segment(3) : $term; 
 
$config = array(); 
 
    $config["base_url"] = base_url() . "User/get_quick_doct/$term"; 
 
    $config['total_rows'] = $this->Search_model->main_search_count($term); 
 
    $config['per_page'] = 5; 
 
    $config['full_tag_open'] = '<ul class="pagination">'; 
 
    $config['full_tag_close'] = '</ul>'; 
 
    $config['first_link'] = false; 
 
    $config['last_link'] = false; 
 
    $config['first_tag_open'] = '<li>'; 
 
    $config['first_tag_close'] = '</li>'; 
 
    $config['prev_link'] = 'Prev'; 
 
    $config['prev_tag_open'] = '<li class="prev">'; 
 
    $config['prev_tag_close'] = '</li>'; 
 
    $config['next_link'] = 'Next'; 
 
    $config['next_tag_open'] = '<li>'; 
 
    $config['next_tag_close'] = '</li>'; 
 
    $config['last_tag_open'] = '<li>'; 
 
    $config['last_tag_close'] = '</li>'; 
 
    $config['cur_tag_open'] = '<li class="active"><a href="#">'; 
 
    $config['cur_tag_close'] = '</a></li>'; 
 
    $config['num_tag_open'] = '<li>'; 
 
    $config['num_tag_close'] = '</li>'; 
 
    $this->pagination->initialize($config); 
 
$data['quick_doc'] = $this->Search_model->fetch_data($config['per_page'], $offset,$term); 
 
$data['get_specs'] = $this->specialisation_model->get_specialisation(); 
 
$data['get_specs'] = $this->specialisation_model->specialisation_get(); 
 
if($data){ 
 
$this->load->helper(array('form', 'url')); 
 
$this->load->view('customer/header', $data); 
 
$this->load->view('customer/side_view',$data); 
 
$this->load->view('customer/quick_search',$data); 
 
$this->load->view('customer/footer'); 
 
     } 
 
else{ 
 
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">No sdfdsfds Results available for your search!!!</div>'); 
 
$this->load->view('customer/header', $data); 
 
$this->load->view('customer/side_view',$data); 
 
$this->load->view('customer/main_search'); 
 
$this->load->view('customer/footer'); 
 
}}

這裏的問題是拼版作業只有一個頁面點擊一個鏈接顯示相同的項目在這裏只顯示5內容僅供完全超過5個項目,但下一個頁面顯示相同的元素

+0

我不知道你明白'''GET'''''' POST'''和URL的路由的代碼或沒有。但是您接受''''term'''作爲''''''''參數,而在控制器函數中您接受'''offset'''作爲'''GET'''參數。在分頁中,您將''term'''作爲'''GET'''參數傳遞。當你去下一頁時,它會找到'''text'''而不是數字,因此失敗。 – kishor10d

+0

我不明白 –

+0

去分頁的文檔,你得到的東西我在說什麼 – kishor10d

回答

2

嘗試這樣的功能,一定會解決你的問題。我再次請求你去尋求更多理解的文檔。

function get_quick_doct() 
{ 
    $term = ($this->input->post("term"))? $this->input->post("term") : ""; 

    $config = array(); 
    $config["base_url"] = base_url() . "User/get_quick_doct/"; 
    $config['total_rows'] = $this->Search_model->main_search_count($term); 
    $config['per_page'] = 5; 
    $config['full_tag_open'] = '<ul class="pagination">'; 
    $config['full_tag_close'] = '</ul>'; 
    $config['first_link'] = false; 
    $config['last_link'] = false; 
    $config['first_tag_open'] = '<li>'; 
    $config['first_tag_close'] = '</li>'; 
    $config['prev_link'] = 'Prev'; 
    $config['prev_tag_open'] = '<li class="prev">'; 
    $config['prev_tag_close'] = '</li>'; 
    $config['next_link'] = 'Next'; 
    $config['next_tag_open'] = '<li>'; 
    $config['next_tag_close'] = '</li>'; 
    $config['last_tag_open'] = '<li>'; 
    $config['last_tag_close'] = '</li>'; 
    $config['cur_tag_open'] = '<li class="active"><a href="#">'; 
    $config['cur_tag_close'] = '</a></li>'; 
    $config['num_tag_open'] = '<li>'; 
    $config['num_tag_close'] = '</li>'; 
    $this->pagination->initialize($config); 

    $segment = $this->uri->segment (2); // 2 or 3 -- as per your url depth 

    $data['quick_doc'] = $this->Search_model->fetch_data($config['per_page'], $segment, $term); 
    $data['get_specs'] = $this->specialisation_model->get_specialisation(); 
    $data['get_specs'] = $this->specialisation_model->specialisation_get(); 
    if($data) 
    { 
     $this->load->helper(array('form', 'url')); 
     $this->load->view('customer/header', $data); 
     $this->load->view('customer/side_view',$data); 
     $this->load->view('customer/quick_search',$data); 
     $this->load->view('customer/footer'); 
    } 
    else{ 
     $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">No sdfdsfds Results available for your search!!!</div>'); 
     $this->load->view('customer/header', $data); 
     $this->load->view('customer/side_view',$data); 
     $this->load->view('customer/main_search'); 
     $this->load->view('customer/footer'); 
    } 
} 
+0

tkz kishor它的工作yaa !!!! –