i'm making a searcher for my site and this works fine with one word querys
$consulta = mysql_query("SELECT * FROM recetas WHERE (titulo LIKE '%$busqueda%' OR intro LIKE '%$busqueda%' OR extra LIKE '%$busqueda%') ORDER BY id DESC");
But if i type 'two words' it doesn't give me result, $busqueda
it's result from a <input/>
given through $_POST['TERM']
any idea what i'm missing?
SOLVED
i was missing to encode the variable to URI... oops haha THANKS!
Think of how your query will look at the end:
If you want to search for words like that, you'll have to massage the data to look more like:
depending on your exact search requirements
where ( MATCH( titulo, intro, extra) AGAINST ('word1 word2' in BOOLEAN MODE))
Unless the two words are adjacent in the text, the LIKE operator won't find them. You may want to use full text search.
In order to find two non-contiguous words, the input would need to be split up into two separate values and the query would have to look something like this:
That is assuming you want a match with either word. If both must match, then something like this:
And one other thing. It would be better to use parameterized queries to avoid an SQL injection.