Hi,
I'm doing a simple search through a database for keywords, but when i'm searching for multiple keywords, it's searching it as a phrase and I don't want that. I would like to search for each word in the phrase just like a regular search.
Here's my script as of right now:
<?
$for = "word1 word2 word3";
$query = "SELECT * FROM tablename WHERE (field1 like '%$for%') OR (field2 like '%$for%') OR (field3 like '%$for%')";
@($query);
?>
Now, the way it is, it only returns true if field1, field2, or field3 contain the phrase "word1 word2 word3" - I want it to return true if either of the fields contain any of the words in the phrase. I've thought about doing the $for as an array, but I'm not really sure how to do the search.... is it possible to search for an array in a query like that? Something like this:
<?
$for[] = "word1";
$for[] = "word2";
$for[] = "word3";
$query = "SELECT * FROM tablename WHERE (field1 like '%$for[]%') OR (field2 like '%$for[]%') OR (field3 like '%$for[]%')";
@($query);
?>
I haven't tested it like that cause I just thought of it, but is that possible? Does anyone have any better ideas of how to do this type of search?