2016-12-08 197 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 !!!! –