<?php include("script/function/config.php");
if(isset($_GET[q])) {
$q = mysqli_real_escape_string($conn, $_GET[q]);
$q = trim($q);
$w = preg_split("/[ ]{1,}/", $q);
$pname = array();
foreach($w as $k) {
$x = "('pname' LIKE '%".$k."%')";
array_push($title, $x);
}
$pname=implode(" OR ", $pname);
$pth_name = array();
foreach($w as $k) {
$x = "('pth_name' LIKE '%".$k."%')";
array_push($pth_name, $x);
}
$pth_name=implode(" OR ", $pth_name);
$condition="$pname OR $pth_name";
$shsql=mysqli_query($conn, "SELECT * FROM 'post' WHERE $condition");
$count=mysqli_num_rows($shsql);
}
?>
<?php
if($count == 0) {
echo "NOT FOUND! ".stripslashes($q);
} else {
$p=implode("|", $w);
$p="/$p/i";
while ($row = mysqli_fetch_array($shsql)) {
$title=preg_replace($p, "<b>\\0</b>", $row['pname']);
$thtitle=preg_replace($p, "<b>\\0</b>", $row['pth_name']);
?><a href="view.php?pid=<?=$row[pid];?>" ?><?=$title;?> <?=$thtitle;?></a><br>
<?php } } ?>
ค้นแล้วไม่เจออะไรเลยครับ ชื่อก็ตรงแล้ว