title: php - Mysql Query working except one filter
body: <p>I have below given query which is working except one filter</p>
  
  <pre><code>$sql='select * from zonez WHERE zoneprice between :minprice and :maxprice';
      if(!empty($sizes)){
          $sql .='  AND FIND_IN_SET(zonesize,:sizes)';
      }
  
      if(!empty($categories)){
          $sql .='  AND FIND_IN_SET(webcategory,:categories)';
      }
  
      if(!empty($minimp)){
          $sql .='  AND websrid IN (SELECT web from stats WHERE time &gt; UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 24 HOUR)) GROUP BY srid HAVING  SUM(wh*30) between :minimp and :maximp)';
      }
  
      if(!empty($search)){
          $sql .='  AND websrid IN (SELECT srid FROM websitez WHERE webtitle LIKE :search)';
      }
  
  
      if(!empty($type)){
          $sql .='  AND FIND_IN_SET(zonetype,:type)';
      }           
  
      $sql .=' group by misc1';
  </code></pre>
  
  <p>Query Binding code</p>
  
  <pre><code>$stmt=$this-&gt;conn-&gt;prepare($sql);
  
              $stmt-&gt;bindValue(":minprice",$minprice,PDO::PARAM_STR);
              $stmt-&gt;bindValue(":maxprice",$maxprice,PDO::PARAM_STR);
  
          if(!empty($sizes)){
              $stmt-&gt;bindValue(":sizes",$sizes,PDO::PARAM_STR);
          }       
          if(!empty($type)){
              $stmt-&gt;bindValue(":type",$type,PDO::PARAM_STR);
          }
  
          if(!empty($categories)){
              $stmt-&gt;bindValue(":categories",$categories,PDO::PARAM_STR);
          }
          if(!empty($search)){
  
              $stmt-&gt;bindValue(":search","%$search%",PDO::PARAM_STR);
          }
  
  
  
          if(!empty($minimp)){
  
              $stmt-&gt;bindValue(":maximp",$maximp,PDO::PARAM_STR);
              $stmt-&gt;bindValue(":minimp",$minimp,PDO::PARAM_STR);
  
          }
  
          $stmt-&gt;execute();       
          $resultRow=$stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
          if($stmt-&gt;rowCount() &gt; 0){
              return $resultRow;      
          }else{
              return false;
          }   
  </code></pre>
  
  <p>I get $minprice and $maxprice from url as &amp;prices=0-10,20-30,5-10</p>
  
  <pre><code>$prices=$_GET['prices'];
  $gradeprice = str_replace('-', ',', $prices);
  $gradepricee=rtrim($gradeprice,',');
  
  $pricenumber = explode(',', $gradepricee);
  $maxprice = max($pricenumber) ?: "5000";
  $minprice = min($pricenumber) ?: "0";
  </code></pre>
  
  <p>This query get parameters from url 
  resutls/?page=1&amp;categories=1,2&amp;sizes=3,4&amp;prices=0-10&amp;imp=2000-1000000&amp;type=1,2&amp;search=blog&amp;sort=1</p>
  
  <p>This query is working except zoneprice filter. This query output results irrespective of <strong>zoneprice between :minprice and :maxprice</strong> Always the zone price between condition is ignored. I tried all possible ways in this filter but this does not effect this query.</p>