'mysql, php jquery.autocomplete single row search using multipule :term words

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 1:[1]

Split the term and then do the query like this:

SELECT ProductName FROM Products WHERE ProductName LIKE :term[0] AND ProductName LIKE :term[1]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vinicio