首先,我要感谢帮助我创建了一个非常好的搜索结果查询。希望各位朋友能帮我改进一下。
这是查询
$searchresult = $mysql->query("SELECT * FROM pages WHERE PageContent LIKE '%$searchTerm%'");
if($searchresult->num_rows > 0) {
while (($row = $searchresult->fetch_assoc()) !== null)
{
echo '<h3>' . $row["PageTitle"] . '</h1>';
$position = strpos($row["PageContent"], $search);
$snippet = substr($row["PageContent"], $position - 200, $position + 200);
echo $snippet . '<hr><br />';
}
} else {
echo "<p>Sorry, but we can not find an entry to match your query</p><br><br>";
}
我喜欢做的是以不破坏任何单词的方式修剪片段,以便句子可读......并且如果可能的话,使搜索词以粗体显示。亲爱的朋友们,我需要你的帮助。谢谢大家。