Welcome Guest, Not a member yet? Register   Sign In
Find words form same column in Database (Search)
#2

(10-20-2015, 09:28 PM)ardavan Wrote: Hi,

im not sure my thread subject is clear or not. anyway I'm creating a search in my project.
Now I'm getting the words from search input into an array

User will key in ( php programming language ).


PHP Code:
$words explode(' '$search_text); 

Code:
$words = array('php', 'programming', 'language');

Now i need to find any TITLE match with 'php' or 'programming' or 'language'.

my DataBase is like this

Code:
TITLE         |   DESC   |   STATUS
====================================
php coding    |   blabh  |   LIVE
codeigniter 3 |   blaaaa |   LIVE
all language   |   blaaaa |   LIVE

I'm expecting to get the result like this

Code:
TITLE         |   DESC   |   STATUS
====================================
php coding    |   blabh  |   LIVE
all language   |   blaaaa |   LIVE
"Because we have php in the first title and we have language in the second title"

Im trying to get expected result like this

PHP Code:
$this->db->where_in('TITLE'$words); 

The Issue is i can only get one of my rows. (php coding)

How to make it?
Any idea?

Thanks a lot guys.

You could use like() and or_like()


PHP Code:
$this->db->like('TITLE'$words[0]);

for (
$i 1$i count($words); $i++)
{
    $this->db->or_like('TITLE'$words[$i]);

Reply


Messages In This Thread
RE: Find words form same column in Database (Search) - by pdthinh - 10-20-2015, 09:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB