SQL query Where Between two input

Question

I am trying to make a search box but I am facing an issue. Here's the query i am using, I am getting the search query from database,But query is not taking the Fiyat(price),meterekare,odasayisi values from database My question is that Why I am unable to filter the search result by Fiyat (Price)?

if (isset($_SESSION['id'])){
$stmt = $dbh->prepare("SELECT * FROM searclog WHERE sessionid = '".$_SESSION['id']."'"); 
$stmt->execute(); 
$row = $stmt->fetch();
         if ($row){
        $kategori = $row['catid'];
        $satkira = $row['satkira'];
        $searchbox = $row['searchbox'];
        $kelime = $row['city'];
        $fiyataraligi1 = $row['fiyat1'];
        $fiyataraligi2 = $row['fiyat2'];
        $metrekare1 = $row['metrekare1'];
        $metrekare2 = $row['metrekare2'];
        $odasayisi = $row['odasayisi'];
        }
if(isset($_POST)){
                    $join = '
       SELECT
      ilanbasi.product_id,
      ilanbasi.fiyat,
      ilanbasi.ilanbasligi,
      ilanbasi.sahibinden,
      ilanbasi.metrekare,
      ilanbasi.fiyatkuru,
      ilanbasi.odasayisi,
      ilanarasi.tamadres,
      ilanarasi.ililce,
      products.emlakuserid,
      products.satkira,
      products.kategori
    FROM products
      INNER JOIN ilanbasi
        ON ilanbasi.product_id = products.emlakuserid 

      INNER JOIN ilanarasi 
        ON ilanarasi.product_id = products.emlakuserid 
        where (products.eonay = 1 and fiyat between "'.$fiyataraligi1.'" and "'.$fiyataraligi2.'" or ililce like "%'.$kelime.'%" and satkira like "%'.$satkira.'%"  and ilanbasligi like "%'.$searchbox.'%"  and kategori like "%'.$kategori.'%" or odasayisi like "%'.$odasayisi.'%"  and metrekare between "'.$metrekare1.'" and "'.$metrekare2.'")
    ORDER BY products.emlakuserid';
      $stmt = $dbh->prepare($join);
                $stmt->execute();
                $join = $stmt->fetchAll();  

Show source
| pdo   | php   | search   | between   | where   2017-01-06 22:01 0 Answers

Answers ( 0 )

◀ Go back