Code: Select all
$w=array();
if (!empty($RPrice)) $w[]="price='".mysql_real_escape_string($RPrice)."'";
if (!empty($RType)) $w[]="type='".mysql_real_escape_string($RType)."'";
if (!empty($RRAtmosphere)) $w[]="atmosphere='".mysql_real_escape_string($RAtmosphere)."'";
if (!empty($RArea)) $w[]="area='".mysql_real_escape_string($RArea)."'";
if (count($w)) $where="WHERE ".implode(' AND ',$w); else $where='';
$sql="SELECT * from Foodlist $where";
foo1
atmosphere = dark
area = north
foo2
atmosphere = light
area = south
if i run a query (with price and type being empty) with the parameters dark and south, it will return foo2 (it want it to return nothing). where is my logic error?
if you need more information to clarify things, please let me know.