I have a PHP variable with a set value ($v = 12;)
I have a MySQL table named codes with a column named reasons.
I need to write a PHP script that looks to see if 12 is a value in ANY record in the codes table under the reasons column. If 12 is in the table, it is only in once.
If the script finds that 12 does exist in the table and column, the value of $v remains 12.
But if the script finds that 12 does NOT exist in the table and column, then $v is reassigned a value of "default"
Please help me edit my code below
$v = 12;
$sql = sprintf("SELECT reasons FROM codes");
$q = mysql_query($sql);
while($r = mysql_fetch_array($q))
//HERE IS WHERE I GET STUCK
If true, then $v = 12;
If false, then $v = 'default';