当我搜索某个单词时,它会显示结果,但是当我搜索某个具有两个单词的内容时,它不显示结果。可能是由于他们之间的空间......任何解决方案?由于搜索输入空间不足,提交搜索不起作用
This is the code which I am using:
<?php include("config.php");
include("session-user.php");
if(isset($_POST['search']) && $_POST['search'] != "") {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = "SELECT * FROM tbl_product WHERE product_title LIKE '%$searchq%' and is_delete = '0'";
$sql=mysqli_query($con,$query);
$count = mysqli_num_rows($sql);
while($row = mysqli_fetch_array($sql)){
$product_title = $row['product_title'];
$id = $row['product_id'];}?>
<script>
window.location="product.php?pid=<?php echo $id?>";
</script>
<?php
}
?>
<div class="ui-widget">
<input id="automplete-3" type="text" class="form-control" placeholder="Search" name="search">
</div>
使用TRIM(),如'$ SEARCHQ =修剪($ _ POST ['搜索']);'它将删除不在2个字符或单词之间的尾部空格。 – RJParikh
'$ searchq = preg_replace(“#[^ 0-9a-z] #i”,“”,$ searchq);'这会隐藏您的空间 – Saty