I have the following php code:
mysql_query("SELECT a FROM b WHERE b.c = '".$_REQUEST['companyName']."'");
I also have a string:
$mynumbers = "AND b.question_code IN (1);";
How can I combine this string withing the mysql_query()?
Thanks,
mysql_query("SELECT a FROM b WHERE b.c = '".$_REQUEST['companyName']."' " . $mynumbers);
But keep in mind that AND GROUP BY all_surveys.question_code IN (1); is incorrect sql and makes no sense.
First is, you can not combine above two statements, the alternatively you can do like this- //Here i assume that you want to concatenate 2nd condition on particular situation so you need to add if condition or else you can directly contcate it with "." (dot) operator.
$query = "SELECT a FROM b WHERE b.c = '".$_REQUEST['companyName']."'";
if(//your condition) $query .= "AND GROUP BY b.question_code IN (1);";
mysql_query($query);
mysql_query