-1

OK i will write as clear as possible

it's an e-commerce web site and there is a lot of goods

so i have a searching form that send's the input to a php script via jquery's post

method(ajax) now what i want to do is to check if the input (from the form) is equal

or close to one of the word's in my DB but i cant write a regexp for every single word so is

there a solution ???

for example if the client want to see our offers for pentuim 4 and he wrote peniuom it should tell that "do you mean pentuim"

i hope that i can get an answer now

Qchmqs
  • 1,803
  • 2
  • 20
  • 29
  • exact duplicate of [Using regular expression to search within a database using php](http://stackoverflow.com/questions/6888374/using-regular-expression-to-search-within-a-database-using-php) – genesis Jul 31 '11 at 20:15
  • if it a dupplicate can u please give me an answer ?? – Qchmqs Jul 31 '11 at 20:16
  • i was the one who asked the first quesion and stil dont get an answer – Qchmqs Jul 31 '11 at 20:16
  • i didnt get an answer why not respond me in this question instead of closing it like the other one ??? i am asking here because i really can't find an answer – Qchmqs Jul 31 '11 at 20:18
  • I am sorry for this downvoting and closing. Seems to be that your English was not accepted. Please write down more cases: What strings are in the DB, what strings are candidates to be tested. You already mentioned: DB-laptop test-laptoooop. Is it true, that you want to return laptop from the DB if the user searchs for laptooop? – Kaken Bok Jul 31 '11 at 20:37

1 Answers1

1

You could just send the user input to a LIKE query and get the database to do the search work - they are pretty good at that :-)

If there are no results for an exact match then you could pass the search terms through a spell-checker first or use a fuzzy search.

How do I do a fuzzy match of company names in MYSQL with PHP for auto-complete? might also help.

Community
  • 1
  • 1
andyb
  • 43,435
  • 12
  • 121
  • 150
  • OK i will write as clear as possible it's an e-commerce web site and there is a lot of goods so i have a searching form that send's the input to a php script via jquery's post method(ajax) now what i want to do is to check if the input (from the form) is equal or close to one of the word's in my DB but i cant write a regexp for every single word so is there a solution ??? – Qchmqs Aug 01 '11 at 06:28
  • Regex is not the solution here. A _fuzzy_ search or a possibly a _[find as you type](http://jqueryui.com/demos/autocomplete/)_ solution, or combination of both, is the best approach here. – andyb Aug 01 '11 at 07:48