我正在创建一个网站,并且在网站内会有一个搜索框,可让您搜索网站上的项目。我有代码,但我不断收到错误消息。
<?php
include 'connect.php';
$search = $_POST['search']."*";
$search_query = $link->prepare("SELECT name FROM products WHERE MATCH(name)
AGAINST (? IN BOOLEAN MODE)")
$search_query->bind_param('s', $search);
$search_query->execute();
$search_query->store_result();
$search_rows = $search_query->num_rows;
$search_query->bind_result($product_name);
if($search_rows > 0){
while($search_query->fetch()){
echo "Your search returned $search_rows results";
echo $product_name."<br>";
}
} else { echo "Your search returned no results, sorry :("; }
是否可以使用数据库中的 mysql 查询来运行搜索以返回搜索?
任何建议将不胜感激。
谢谢