You are here: Re: unordered word search « PHP Programming Language « IT news, forums, messages
Re: unordered word search

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация