I want to pull information down from a MySQL databse. If the row is populated, then it displays the information properly. However, if the row is empty, It leave the information blank. I want to replace this blank area with a default message. Here is an example of my code:
Code:
<?php
$con = mysql_connect($host, $user, $pass);
mysql_select_db($db, $con);
$sql = mysql_query("SELECT * FROM $table");
while ($row = mysql_fetch_array($sql)
{
echo $row['user']." - ".$row['gender'];
}
?>
The user field is required so there is always information set for that, but the gender field is optional. If the user has not opted to specify a gender, I want a message that says '<Not Specified>'.
I know I can set this as the default in the MySQL database, but I don't want to. How can I do this?
|