Hi. I'm unsure how to break a query up. Any advice. My current query is:
$query = "SELECT FROM general WHERE $item LIKE '%$string%' ORDER BY
faultno"
I am using the above query to search for 'faults' in a database using a text
box ($string) for the search criteria and a drop down box ($item) to select the column names.
If was to type in: "broken box" it would find it ok. However if I was to
type in "box broken" then the above search algorithm wouldn't find the
fault.
How do I break up the search string to be able to find the key words
"broken" and "box"?
Thanks for your time
PS. I have also tried to use this syntax, without luck
$words = explode(" ", $string);
-
$query = "SELECT * FROM general WHERE ";
foreach ($words as $word) {
$query .= " (item LIKE '%$word%' ";
}
** mainly because I need and AND in there.