在笨

2016-12-05 44 views
1

多個搜索我做的代碼點火器多個搜索列表中顯示三個選擇框 專業化,區,將充分上市,成功在笨

爲MyModel

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(); 

var_dump($query);die(); 
      return $query; 
} 

我控制器

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'); 
} 

返回查詢show null v ALUE

+0

這是重複的問題問了兩遍!我也爲它提供瞭解決方案。這裏的鏈接,如果我錯了 http://stackoverflow.com/questions/40902542/filtering-and-search-in-code-igniter?noredirect=1#comment69152055_40902542 –

回答

0

在模型中的代碼應該是

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(); 

var_dump($query);die(); 
      return $query; 
} 

讓我們解釋%通配符在SQL LIKE條件是如何工作的。 請記住,%通配符匹配任何長度爲 (包括零長度)的任何字符串。

檢查鏈接https://www.techonthenet.com/sql/like.php

+0

相同的錯誤是顯示返回空值 –

+0

http: //stackoverflow.com/questions/40902542/filtering-and-search-in-code-igniter/40924881#40924881 –

+0

這是你的鏈接工作? –