Output custom messages based on row value
Posted
by decimal
on Stack Overflow
See other posts from Stack Overflow
or by decimal
Published on 2010-04-20T19:06:10Z
Indexed on
2010/04/20
19:13 UTC
Read the original article
Hit count: 168
I've made a simple guestbook mysql/php page. An entry is displayed if the approve column has a value of 1. For the adminstrator, I want to display either "message approved" or "not approved". Here's my code:
while ($row = mysql_fetch_array ($r)) {
print "<p>Guest:" .$row['name']. "</p>
<p>Date:" .$row['date']. "</p>
<p>Comment:". $row['comment']. "</p>";
if ($row['approve'] = '1') {
print '<p>YES, the message has been approved</p>';
} else {
print '<p>NO, it hasn\'t been approved</p>';
}
Whatever value the if statement checks approve is equal to, all approve values are output as that value.
© Stack Overflow or respective owner