My users put search terms in an input field. The script I'm using stores that in a $find variable. It then searches mysql like so:
"select * from mytable WHERE title LIKE '%$find%' or description LIKE '%$find%'";
I want to be able to pull a result, even if 1 word is in the title and another in the description, which currently doesn't happen. So.. I'm guessing I need to break the $find variable into an array with a function. After that, how would I do the search in mysql? Since I never know how many words will be in the search (they might decide to search for 8 words at once), how do I reference the array in the mysql query?
Thx in advance!
$find
is a long string (i.e. multiple words), the query will only find results that have the exact same string as is. You need to separate the words and append each one to the query, or use MySQL Full-text search feature. – Aziz Apr 28 '12 at 21:06