如何通过某个关键字搜索元素?

时间:2017-04-11 07:48:23

标签: javascript php codeigniter

查看

<form action="<?php echo base_url()?>user/category" method="post">
<label>Hr</label>
    <input type="checkbox" name="check[]" value="hr"/>
    <label>Developer</label>
    <input type="checkbox" name="check[]" value="Developer"/>
    <label>Designer</label>
<input type="checkbox" name="check[]" value="Designer"/>
<label>CEO</label>
<input type="checkbox" name="check[]" value="CEO"/>
<label>Developer/Designer</label>
<input type="checkbox" name="check[]" value="Developer,Designer"/>
<input type="submit" value="submit"/>

模型

 function category($data){
            $this->db->select("*");
            $this->db->from("data");
            $this->db->where_in('profile',$data);
            $query =  $this->db->get();
            return $query->result_array();
        }

控制器

function category(){
    $details =$this->input->post('check');
    if(!isset($details)){
        $this->Ulogin();
    }
    else
    {
     $details =$this->input->post('check');
    // var_dump($details);
    $data = $this->user_model->category($details);
    var_dump($data);
    }
}

当我搜索developer/designer之类的单个字符串时,它正在运行,但它没有返回其字符串列如developerdesigner的字符串。我想要 当我搜索开发者时,它应该返回其个人资料为developerdeveloperdesigner两者。

1 个答案:

答案 0 :(得分:1)

使用类似查询

$this->db->like('keywords',$keywords);
$this->db->where("condition","condition");
$query = $this->db->get("tbl_name");