Hello all-
I have this SQL statement:
$query = "SELECT food_quality, COUNT(food_quality) as cnt FROM surveyData WHERE `bizID`='$key' GROUP BY food_quality";
And I want to run this PHP function in it:
function checkifmaster()
{
if ($key == 1) {
echo "";
}
else {
echo "WHERE `bizID`='$key'";
}
}
Ideally I would like to remove the WHEREbizID='$key' filter in the SQL query depending if 1 is passed or not.
Any ideas on how to format this?
Can I write the SQL statement like this with the Php function in the query?
$query = "SELECT food_quality, COUNT(food_quality) as cnt FROM surveyData 'checkifmaster()' GROUP BY food_quality";