过滤并搜索代码点火器

时间:2016-12-01 04:15:41

标签: codeigniter search filtering

我正在进行过滤和搜索,但不知道!怎么样? 但我尽我所能,但失败! 在这里,我显示列表由ajax显示的列表 成功

enter image description here 我的数据库是 enter image description here enter image description here 我的控制器是



  public function get_quick_search() 
{
        $sepcli= $this->input->post('spec');
     	$distct= $this->input->post('dist');
     	$locat= $this->input->post('locat');
         $data['list'] = $this->Doctor_model->search_listing();
        $data['quck_search'] = $this->search_model->get_quick_list($sepcli,$distct,$locat);
        $data['get_specs'] = $this->specialisation_model->get_specialisation();
        $this->load->helper(array('form', 'url'));
        $this->load->view('customer/header');
        $this->load->view('customer/side_view',$data);
        $this->load->view('customer/quick_search',$data);
        $this->load->view('customer/footer');
}




我喜欢的模特



 public  function get_quick_list($locat,$distct,$sepcli)  
{  
    $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("(district LIKE '$distct' AND place LIKE '$locat' AND spec_specialise LIKE '$sepcli')");

    $query=$this->db->get()->result_array(); 

 
          return $query;
}




这里没有错误显示,但返回查询是空的,如下所示(数组(0){})

1 个答案:

答案 0 :(得分:3)

您可能会尝试这样,您的控制器功能代码

public function get_quick_search()
{
        $s_data['sepcli'] = $this->input->post('spec');
        $s_data['distct'] = $this->input->post('dist');
        $s_data['locat']  = $this->input->post('locat');


        $data['quck_search'] = $this->search_model->get_quick_list($s_data);
        $data['get_specs'] = $this->specialisation_model->get_specialisation();
        $this->load->helper(array('form', 'url'));
        $this->load->view('customer/header');
        $this->load->view('customer/side_view',$data);
        $this->load->view('customer/quick_search',$data);

        $this->load->view('customer/footer');
}

你的模型功能代码

public  function get_quick_list($s_data)  
{  
    $this->db->select('td.*, ts.*')
    $this->db->from('tbl_doctor as td');    
    $this->db->join('tbl_specialisation as ts', 'ts.spec_id = td.spec_id','left');

    if($s_data['sepcli'] !="")
       $this->db->like('ts.spec_specialise',$s_data['sepcli'],'both');
    if($s_data['distct'] !="")
       $this->db->like('td.district',$s_data['distct'],'both');
    if($s_data['locat'] !="")
       $this->db->like('td.place', $s_data['locat'], 'both');

    $query=$this->db->get()->result_array(); 
    return $query;
}
确定它会有所帮助,你应该试试!!!