How to do an IF statement based on the value of a MySQL table cell?
- by Susan
How can I do an if statement based on the value of a mysql table cell. For example, I have a table of people with a column called marital_status. This column has one of two values: yes or no. But this doesn't work:
$query = mysql_query("SELECT marital_status FROM people WHERE first_name = 'John'");
while ($row = mysql_fetch_assoc($query)) {
$maritalStatus = $row['marital_status'];
}
if ($maritalStatus == "yes") {
echo "This person is married.";
}
else {
echo "This person is NOT married.";
}
$maritalStatus == "yes" doesn't return as true even though that is exactly the value in that cell.