任何帮助将非常感激?
问题是搜索按钮完成了它的功能。该页面应该只显示与产品关键字匹配的产品,它只显示与相关关键字匹配的产品,但它会显示 0.1 毫秒,然后重新加载以显示整个页面。但是,如果我只单击一个类别选项卡,即床/沙发(在我的情况下)。它只是向我显示床或沙发的产品,不会重新加载。这与我想要的搜索按钮相同。编辑:我已经尝试过preventDefault,但它不起作用请参阅下面的相关代码:
索引.php
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" id="search">
</div>
<button type="submit" class="btn btn-primary" id="search_btn"><span class="glyphicon glyphicon-search"></span></button>
</form>
动作.php
if(isset($_POST["get_seleted_Category"]) || isset($_POST["selectBrand"]) || isset($_POST["search"])){
if(isset($_POST["get_seleted_Category"])){
$id = $_POST["cat_id"];
$sql = "SELECT * FROM products WHERE product_cat = '$id'";
}else if(isset($_POST["selectBrand"])){
$id = $_POST["brand_id"];
$sql = "SELECT * FROM products WHERE product_brand = '$id'";
}else {
$keyword = $_POST["keyword"];
$sql = "SELECT * FROM products WHERE product_keywords LIKE '%$keyword%'";
}
$run_query = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($run_query)){
$pro_id = $row['product_id'];
$pro_cat = $row['product_cat'];
$pro_brand = $row['product_brand'];
$pro_title = $row['product_title'];
$pro_price = $row['product_price'];
$pro_image = $row['product_image'];
echo "
ABOUTYOU
拉风的咖菲猫