搜索栏无法正常工作

时间:2014-12-13 15:56:53

标签: php mysql search

您好,当我从其插入MYSQL的关键字中搜索产品时,所有产品都出现在结果中,请帮我这是搜索代码

if(isset($_GET['search'])) {

    $search_query = $_GET['user_query'];
    $get_pro = "select * from products where product_keywords like '%$search_query%'";

    $run_pro = mysqli_query($con, $get_pro);

    while($row_pro = mysqli_fetch_array($run_pro)) {

        $pro_id = $row_pro['product_id'];    
        $pro_cat = $row_pro['product_cat'];    
        $pro_brand = $row_pro['product_brand'];    
        $pro_title = $row_pro ['product_title'] ;    
        $pro_price = $row_pro['product_price'];    
        $pro_image = $row_pro['product_image'];

        echo "
          <div id='single_product'>    
            <h3 id='product_title'>$pro_title</h3>    
              <img src='admin_area/product_images/$pro_image' width='180' height='200' />   
              <p><b> $ $pro_price <b></p>   
              <a id='details-button' href='details.php?pro_id=$pro_id'>Details</a>   
              <a href='index.php?pro_id=$pro_id'><button class='button'>Add to Cart</button></a>   
          </div>
        "; 
    }
 }

0 个答案:

没有答案