hi, i have an SQL string: <?php $sql = mysql_query("select * from products where category='$cat' and manufact='man' and status=1 order by price") ?> PHP: i want when the man <> "" to have this statement in the SQL string and manufact='"&man&"' but when man = "" i don't want to have this statement. can anybody tell me what can i do?
Hi, try this: $sql=($man!='')?mysql_query("select * from products where category='$cat' and manufact='$man' and status=1 order by price"):mysql_query("select * from products where category='$cat' and status=1 order by price"); PHP: I guess you mean var $man Regards
isn't another way without SQL replacement? i want (if possible) to write the replacement inside the SQL Query
$sql = mysql_query("select * from products where category='$cat' and status=1 and IF('$man'='',1,manufact='$man') order by price"); PHP: