need a code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sadafrasheed
Forum Newbie
Posts: 1
Joined: Tue Aug 10, 2004 2:51 am

need a code

Post by sadafrasheed »

hi!!
i need a code that can search database for keywords. the special thing is that if user makes a typing mistake,, the code should detect it and should search the database for actual word...
i am sure it must be some where on net but dont have time to seach. if some one knows where to find it plz give me the link. its urgent!!
bye
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Sounds like you need to look at the php command levenshtein and it's "see also links"
http://www.php.net/manual/en/function.levenshtein.php. Depends on what you need to search for. If searching for a specific word in a paragraph within the database it could take a long time to process. The question you need to ask yourself is how to detect when a typing error has occured.

A lot of companies spend a fortune on search algorithms to solve this problem and produce results in reasonable timeframes, therefore they do not give out their code.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

For quick'n dirty search-functionality I'd use MySQL's fulltext. Check the argument "WITH QUERY EXPANSION" - could come in handy, but I'd do some filtering with PHP as CoderGoblin suggested.
Post Reply