2017-05-17 45 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

你能解释一下,你想要实现什么? –

相关问题