![]() |
Searching in codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Searching in codeigniter (/showthread.php?tid=24872) |
Searching in codeigniter - El Forum - 11-23-2009 [eluser]tj[/eluser] hai i need to search a word from a lot of text and display it.it works fine on single word but when we use multiple words separated by a space it doesnot return any value my code is function fetchblogscount($userid,$tag) { $this->db->select(‘feed_info.id, feed_info.title, feed_info.description ‘); $this->db->from(‘feed_info’); $this->db->join(‘feeds’, ‘feed_info.feed_id= feeds.id’); $this->db->where(‘feeds.user_id’, $userid); $this->db->like(‘title’, $tag); $this->db->or_like(‘description’,$tag); $q = $this->db->get(); return $q->result_array(); } tnx in advance Searching in codeigniter - El Forum - 11-23-2009 [eluser]CI Coder[/eluser] [quote author="tj" date="1258977806"]hai i need to search a word from a lot of text and display it.it works fine on single word but when we use multiple words separated by a space it doesnot return any value my code is function fetchblogscount($userid,$tag) { $this->db->select(‘feed_info.id, feed_info.title, feed_info.description ‘); $this->db->from(‘feed_info’); $this->db->join(‘feeds’, ‘feed_info.feed_id= feeds.id’); $this->db->where(‘feeds.user_id’, $userid); $this->db->like(‘title’, $tag); $this->db->or_like(‘description’,$tag); $q = $this->db->get(); return $q->result_array(); } tnx in advance[/quote] Try the following: replace these lines Code: $this->db->like(‘title’, $tag); with these: Code: $this->db->like(‘title’, '%'.$tag.'%'); Searching in codeigniter - El Forum - 11-23-2009 [eluser]Isern Palaus[/eluser] I think that you need to explode the search query and foreach search entry add and a or_like... I think that this will return more results. Regards, Isern Searching in codeigniter - El Forum - 11-24-2009 [eluser]tj[/eluser] $this->db->like(‘title’, '%'.$tag.'%'); $this->db->or_like(‘description’,'%'.$tag.'%'); this will not return any value any other idea Searching in codeigniter - El Forum - 11-24-2009 [eluser]umefarooq[/eluser] just print you query and see what is result Code: echo $this->db->last_query(); Searching in codeigniter - El Forum - 11-24-2009 [eluser]tj[/eluser] i just fount my error .i have to use urldecode($tag). |