我试图运行一个博客网站的搜索查询,我正在工作,我用爆炸功能分离我的搜索字符串,结果当我循环的结果,我得到重复的结果。代码如下
}}else{
$searchbit= explode(" ", $searchterm);
foreach($searchbit as $value){
$metaphonebit =metaphone($value);
$sql = "SELECT blogcontent.title,
blogcontent.content,
blogcontent.blogtimestamp,
blogcontent.views,
blogcontent.image,
blogcontent.author,
blogcontent.tdate,
blogcontent.category,
blogcontent.tags,
categories.banner,
blogcontent.id,
categories.color,
metatext.metatitle,
categories.name
FROM blogcontent
JOIN categories ON blogcontent.category = categories.name
JOIN metatext ON metatext.metaid = blogcontent.id
WHERE (metatext.metatitle LIKE '%$metaphonebit%'
OR metatext.metatags LIKE '%$metaphonebit%'
OR metatext.metacategory LIKE '%$metaphonebit%' )";
$query = $con -> prepare($sql);
$query->execute();
$results=$query->fetchall(PDO::FETCH_OBJ);
if($query->rowCount() > 0) {
foreach($results as $result){ echo htmlentities($result->title);
echo htmlentities($result->category);
所以当我运行它,搜索像smith will这样的东西时,我得到两个结果,比如
威尔·史密斯威尔·史密斯
暂无答案!
目前还没有任何答案,快来回答吧!