mysql, php jquery.autocomplete single row search using multipule :term words
Question
Im working on an autocomplete for a form I'm doing. My question is, how do I pass more than one search :term from jQuery into the mysql SELECT query? Like:
$search_term = "%".$_GET['term']."%";
then:
$query = "SELECT ProductName FROM Products WHERE ProductName LIKE :term AND
ProductName like :term";
But say in the cloumn ProductName a product example would be:
Red Wagon with Gold Rims
I can get it to search for "Red Wagon" or "Gold Rims". But I want to be able to enter:
Red Gold
and have the same ProductName come up. How would I make the words break up and search like that?
Solution
Split the term and then do the query like this:
SELECT ProductName FROM Products WHERE ProductName LIKE :term[0] AND ProductName LIKE :term[1]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow