troubleshooting Question

How to filter product price range using checkbox?

Avatar of Milind Bhuvad
Milind BhuvadFlag for India asked on
4 Comments1 Solution428 ViewsLast Modified:
I created product price filter using checkbox in php. I have 3 price range 2000-3000, 3000-4000, 4000-5000. If user click one checkbox its work, but user click more than one checkbox getting error (Notice: Trying to get property of non-object in D:\xamp\htdocs\aasopalav\controller\filter_saree.php on line 45).

here is my forntend code
<ul class="list-style-6 margin-50px-bottom text-small">
      <li><input type="checkbox" value="2000 AND 3000" class="item_filter price">2000 - 3000</li>
      <li><input type="checkbox" value="3000 AND 4000" class="item_filter price">3000 - 4000</li>
      <li><input type="checkbox" value="4000 AND 5000" class="item_filter price">4000 - 5000</li>

and here is my back end code to filter
   $price = isset($_REQUEST['price'])?$_REQUEST['price']:"";

   $sql = "SELECT * FROM wm_products WHERE pro_live='N'";
                  $price =implode("','",$price);
                  $sql  .= " and pro_price between $price";

$result = $conn->query($sql);
      if($result->num_rows > 0){
            while($row = $result->fetch_assoc()){
                       .........result which checkbox selected

In sort my select query created like this ( SELECT * FROM `wm_products` WHERE pro_live='N' AND pro_price BETWEEN 2000 AND 3000, 4000 AND 5000 )
Dustin Saunders
Co-Founder and Chief Architect
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros