[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);
$this->db->or_like(‘description’,$tag);
with these:
Code:
$this->db->like(‘title’, '%'.$tag.'%');
$this->db->or_like(‘description’,'%'.$tag.'%');