如何检查来自 A DB 的可能接近匹配的输入 [英] How To Check the input for a possible close match from A DB

查看:45
本文介绍了如何检查来自 A DB 的可能接近匹配的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我会尽量写清楚

这是一个电子商务网站,有很多商品

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

所以我有一个搜索表单,它通过 jquery 的帖子将输入发送到 php 脚本

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

method(ajax) 现在我想做的是检查输入(来自表单)是否相等

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

有解决方案吗???

例如,如果客户想查看我们对 pentuim 4 的报价并且他写了 penuom,它应该告诉你是说 Pentuim"吗

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

推荐答案

您可以将用户输入发送到 LIKE 查询并让数据库执行搜索工作 - 他们非常擅长:-)

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.

如何使用 PHP 对 MYSQL 中的公司名称进行模糊匹配以进行自动完成? 也可能有所帮助.

这篇关于如何检查来自 A DB 的可能接近匹配的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆