Multiple conditions php/mysql -
i'm working on multi critera search on php/mysql, search has 5 entries: - type, price min - price max , qty min - qty max :
$type = $_post['type']; $pmin = $_post['pmin']; $pmax = $_post['pmax']; $qtmin = $_post['qtmin']; $qtmax = $_post['qtmax']; $query = "select * products type_product='$type' , price_min<='$pmin' , price_max>='$pmax' , qty_min<='$qtmin' , qty_max>='$qtmax' " ; this works fine, user have fill entries. , idea user can enter type, or type , price, or qty , .. tried use or clause didn't make work well.
where (a = '$a' or '$a' = '') , (b <= '$b' or '$b' = '') , (c >= '$c' or '$c' = '') notice if variable empty string, condition satisfied.
Comments
Post a Comment