Skip to content
Loading
ajax product filter with checkbox convert to radio button  
  •   
  •   
  • class="col-md-9">  
  •   
  • class="row filter_data">  
  •   
  •   
  •   
  •   
  •   
  •   
  •   
  •   
    1. //fetch.php  
    2. include('connect.php');  
    3. if(isset($_POST["action"]))  
    4. {  
    5. $query = "  
    6. SELECT * FROM tbl_product WHERE product_status = '0'  
    7. ";  
    8. if(isset($_POST["minimum_price"], $_POST["maximum_price"]) && !emptyempty($_POST["minimum_price"]) && !emptyempty($_POST["maximum_price"]))  
    9. {  
    10. $query .= "  
    11. AND price BETWEEN '".$_POST["minimum_price"]."' AND '".$_POST["maximum_price"]."'  
    12. ";  
    13. }  
    14. if(isset($_POST["name"]))  
    15. {  
    16. $brand_filter = implode("','"$_POST["name"]);  
    17. $query .= "  
    18. AND name IN('".$brand_filter."')  
    19. ";  
    20. }  
    21. $statement = $connect->prepare($query);  
    22. $statement->execute();  
    23. $result = $statement->fetchAll();  
    24. $total_row = $statement->rowCount();  
    25. $output = '';  
    26. if($total_row > 0)  
    27. {  
    28. foreach($result as $row)  
    29. {  
    30. $output .= '  
    31. class="col-sm-4 col-lg-3 col-md-3">  
    32. "border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; height:450px;">  
    33. "center">"#">'. $row['name'] .'

        
    34. "text-align:center;" class="text-danger" >'. $row['price'] .'  
    35. Brand : '. $row['id'] .'   
      
  •   
  • ';  
  • }  
  • }  
  • else  
  • {  
  • $output = '

    No Data Found

    '
    ;  
  • }  
  • echo $output;  
  • }  
  • ?>
  • 1 Reply

    Know the answer? Post it — somebody with the same question will find it here.