当用户搜索书名时,应使用什么搜索算法来给出结果?将最近的字符串与特定的字符串匹配
如果存在应该返回标题的书,否则必须显示与其接近的书名。
第一种情况更容易搜索字符串。我需要如何解决大多数网站使用的第二种情况。
books表包含字段类别,类别和标题。我已经尝试了下面的代码,当我给出确切的标题时,我会得到结果,我希望系统给予密切相关的标题。
$title=isset($_GET['title'])?$_GET['title']:NULL;
//$code=isset($_GET['code'])?$_GET['code']:NULL;
$class=isset($_GET['class'])?$_GET['class']:NULL;
$cat=isset($_GET['category'])?$_GET['category']:NULL;
if(isset($title))
$qry="select * from books where quantity>0 and title='$title' ";
else{
$qry="select * from books where quantity>0 ";
if(isset($class)) $qry.=" and class='$class' ";
if(isset($cat)) $qry.=" and category='$cat' ";
}
书名如何存储?他们在哪里储存?你已经尝试了什么?我们不在这里进行舀勺。 – Daniel
@Stah我添加了我曾尝试过的东西。 – user6181297