Das ist mein Suchcode, wenn ich auf die Suchschaltfläche klicke, gibt es die Ausgabe aller Werte, anstatt den bestimmten Produkttitel zu suchen.Suche funktioniert nicht mit PHP
Irgendwelche Hilfe ??
<?php include("config.php");
mysqli_select_db("onlinegrocery");
$output = "";
if(isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = "SELECT * FROM tbl_product WHERE product_title LIKE '%$searchq%'";
$sql=mysqli_query($con,$query);
$count = mysqli_num_rows($sql);
if($count == 0) {
$output = 'Nothing Found';
}
else {
while($row = mysqli_fetch_array($sql)){
$product_title = $row['product_title'];
$id = $row['product_id'];
$output .= '<div> '.$product_title.' </div>';
}
}
}
?>
<form action="index.php" method="post">
<input type="text" class="form-control" placeholder="Search">
<div class="input-group-btn">
<button class="btn btn-default" type="submit" name="search"><i class="glyphicon glyphicon-search"></i></button>
</div>
</form>
<?php echo("$output");?>
ich denke, ' "# [^ 0-9a-z] #i" sein' Sie sollten keine Leerzeichen aus der Suchanfrage entfernen. '" # [^ 0-9a-z \ s] #i "' – jekaby