douju6542 2013-07-12 06:20
浏览 8
已采纳

获取与给定输入匹配的名称

am using code as below.according to the review name the details are getting. what i require is if i give a particular word that is for example "san" for searching the names matching to that has to be displayed.that is sangee, santhosh,..... for you to understand example is facebook in which if we go to search and add some name it will be showing the names matching to that in the similar way we require the output for our app. the input should be dynamic. thanks

$this->db->select('reviewee_name');
$this->db->from('reviews');
$this->db->where('reviewee_name', $input['reviewee_name']);
$query = $this->db->get();
  • 写回答

2条回答 默认 最新

  • dongqin1819 2013-07-12 06:27
    关注

    Simply change

    $this->db->where('reviewee_name', $input['reviewee_name']);
    

    Into

    $this->db->like('reviewee_name', $input['reviewee_name']);
    

    Don't do this

    $this->db->like('reviewee_name', '%'. $input['reviewee_name'] .'%');
    

    It creates another % inside %, like this

    WHERE reviewee_name LIKE '%%reviewee_name%%'
    

    For more information visit http://ellislab.com/codeigniter/user-guide/database/active_record.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了