here is the description variable I am echoing from my table:
$description = mysql_result($result,$i,"description");
sometimes the $i'th record is empty and doesn't have any data in it/no description.
What I want to do is echo "No description available" for records that are empty
if (isset($description)){ echo "No description available";}
else{ echo $desctipion;}
My attempt doesn't work though as it then echoes No description available for every record even those which aren't empty.
What is the answer?
isset($description)
will result true because $description is still set, even though its value is 'empty'. What you need to use is empty.
if (empty($description)) {
echo "No description available";
} else {
echo $description;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With