2016-12-01 75 views
1

我正在做一個過濾和搜索,但不知道!怎麼樣? 但我盡我所能,但失敗! 這裏我顯示列表列表是顯示阿賈克斯 是sucess在代碼點火器中過濾和搜索

enter image description here 我的數據底座 enter image description here enter image description here MY控制器

public function get_quick_search() 
 
{ 
 
     $sepcli= $this->input->post('spec'); 
 
     \t $distct= $this->input->post('dist'); 
 
     \t $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'); 
 
}

我的模型LIKE

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

這裏沒有錯誤SHOW但返回的查詢是NULL SHOW像這樣(陣列(0){})

+0

問題在哪裏? –

+0

模型是問題顯示 –

+0

幫我查詢retun null值 –

回答

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

肯定會有幫助,你應該試試看!!!

+0

只是等待,我會嘗試 –

+0

沒問題。 antroo ghosh –

+0

我的清單數據此類型