Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

php - How To Check the input for a possible close match from A DB

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...