|
Posted by iuz on 12/28/05 13:58
correo@ironcito.com wrote:
> Hello,
>
> I've built a search engine that queries a MySQL database. However,
> if I enter "foo bar", the engine will search for that phrase exactly,
> and will not find "bar foo" nor "foo something bar". How do you
> separate words so that the engine finds them individually? I'm thinking
> something like
>
> $tokenized = strtok($query, " ")
> mysql_query(" SELECT ... FROM ...
> while(...){ WHERE ...}
> ")
>
> but I just can't figure it out. Any help is much appreciated. Many
> thanks in advance.
>
> Diego
if you wnat to search these words in this order you can simply do something
like this..
$string = "word0 word1 word2 word3 word4 ";
$words = '%' . preg_replace('/ +/', '%', trim($string)) . '%';
$words = mysql_escape_string($words);
echo "SELECT * FROM table WHERE nn LIKE '$words'";
--
www.iuz-lab.info
[Back to original message]
|