我需要在我的网站上创建搜索功能,但实际上我不知道从哪里开始寻找。
在我的网站上,我有一个搜索表单,需要让用户搜索此示例中的项目:
“亚特兰大的精酿啤酒”
如何将“精酿啤酒”与“亚特兰大”分开制作相应的 查询?
非常感谢。
修改
解决了这个:
if (strpos($search, ' in ') !== false){
$search = $search;
$separate = explode(" in ", $search);
$product = $separate[0];
$place = $separate[1];
$query = "SELECT * from catalog WHERE (`title` LIKE '%$product%' AND `status` = 'active' AND `coverage` LIKE '%$place%') OR (`tags` LIKE '%$product%' AND `status` = 'active' AND `coverage` LIKE '%$place%') OR (`description` LIKE '%$product%' AND `status` = 'active' AND `coverage` LIKE '%$place%') order BY titulo ASC";
}
答案 0 :(得分:0)
解决了这个问题:
if (strpos($search, ' in ') !== false){
$search = $search;
$separate = explode(" in ", $search);
$product = $separate[0];
$place = $separate[1];
$query = "SELECT * from catalog WHERE (`title` LIKE '%$product%' AND `status` = 'active' AND `coverage` LIKE '%$place%') OR (`tags` LIKE '%$product%' AND `status` = 'active' AND `coverage` LIKE '%$place%') OR (`description` LIKE '%$product%' AND `status` = 'active' AND `coverage` LIKE '%$place%') order BY titulo ASC";
}