Page 1 of 1

Search database

Posted: Fri Jun 27, 2003 2:22 pm
by Zeceer
Hi,

I've made search engine on my webshop that works fine, exept that it's only outputting the rows that have a field matching the search word perfect. Here:

Code: Select all

$result = mysql_query( "SELECT * FROM products WHERE category='".$_POSTї'word']."' OR prodnr='".$_POSTї'word']."' OR product='".$_POSTї'word']."'" );
$word is the search string from the search form. Is there any command in mysql or PHP that will make this string find alle the rows containing a specific word?

Now there is like this, if someone search for "socks" and the there is a field containing "super socks" this does not give a hit. You have to search for the exact word. In this case "super socks".

Posted: Fri Jun 27, 2003 2:26 pm
by ILoveJackDaniels
instead of category='".$_POST['word']."' try category like '%".$_POST['word']."%'

Posted: Fri Jun 27, 2003 2:35 pm
by Zeceer
Works fine! Thanks! :D