The following is a mySQL query containing the initial query followed by some additional criteria.
mysql_query("SELECT * FROM electors WHERE telephone > 0 AND last_known_voting_intention = 'P' OR last_known_voting_intention = 'A'");
I want to pass the additional criteria from another page and included in a PHP variable.
$criteria = "AND last_known_voting_intention = 'P' OR last_known_voting_intention = 'A'";
How do I then include that in the mySQL query.
mysql_query("SELECT * FROM electors WHERE telephone > 0 $criteria");
mysql_query("SELECT * FROM electors WHERE telephone > 0 ".$criteria);
These 2 do not appear to work.
Your original query looks like it should to work, but I wouldn’t be surprised if it’s one of PHP’s mysteries.
What you could do is this: