Reputation: 169
Not sure if I'm taking the right approach here. I want something to display only if a value is set in the field. I've tested this several ways.
1) If the value is set, then it displays correctly.
2) If I make up some random variable, then "N/A" is correctly displayed. But,
3) If the value in the field has NO set value, the echoed text still appears and of course without any set value.
if (isset($row['DATE'])) {
echo "Dated: {$row['DATE']} <br />" ;
} else {echo "N/A" ; }
So what am I missing? How do I get this code to recognize and ignore an empty field?
Upvotes: 0
Views: 592
Reputation: 1
I would use another if checking if the value is not set (!isset($row['DATE']))
Rgds.
Upvotes: 0
Reputation: 1260
You looking for empty() function. They will return false if variable is empty or is not set.
Upvotes: 0