2017-05-17 43 views
0

我想笨搜索,如果匹配然後我輸入數據顯示的結果,但不能匹配不能顯示數據..搜索,如果我的輸入數據是匹配或者不

這裏是我的模型:

public function get_search(){ 
    $p_cat = $this->input->post('p_category'); 
    $p_place = $this->input->post('p_place'); 
    $p_price = $this->input->post('p_price'); 
    $search = $this->input->post('search'); 
    $this->db->like('p_category',$p_cat,$search); 
    $this->db->or_like('p_place',$p_place,$search); 
    $this->db->or_like('p_price',$p_price,$search); 
    $query = $this->db->get('tbl_property'); 

    if($query->num_rows() > 0) 
     return $query->result_array(); 
    else 
     return FALSE; 
} 

但這種模式的結果匹配或不匹配它顯示任何數據...

回答

0

你有問題查詢生成器類的你or_like方法調用。它應該是這樣的:

public function get_search(){ 

// Below three lines is not useful until you are using any other conditions to fetch data from DB 
$p_cat = $this->input->post('p_category'); 
$p_place = $this->input->post('p_place'); 
$p_price = $this->input->post('p_price'); 

// I guess this string should be search in three columns 
$search = $this->input->post('search'); 
$this->db->like('p_category',$search); 
$this->db->or_like('p_place',$search); 
$this->db->or_like('p_price',$search); 
$query = $this->db->get('tbl_property'); 

if($query->num_rows() > 0) 
    return $query->result_array(); 
else 
    return FALSE; 
} 

讓我知道你是否仍然面臨任何問題。

+0

相同的結果...沒有解決 – Sabbir

+0

你能解釋一下,你想要實現什麼? –

相關問題