Live search query using JS and PHP for QA forum
PHP Snippet 1:
foreach ($words as $keywords) {
echo $keywords.'<br>';
$keyword = trim($keywords);
if(strlen($keyword)>0){
$sql="SELECT * FROM qa_posts WHERE title like '%".$keywords."%' OR content like '%".$keywords."%' OR tags like
'%".$keywords."%' limit 10 ";
$q=mysqli_query($dbc,$sql);
while($res=mysqli_fetch_array($q)){
echo "<a href='".$res['slug']."'>".$res['title']."</a><br>";
}
}
}