Jason
Jason

Reputation: 93

php: show html if a field in database is NOT empty

I know this question in some form has been asked before, but somehow it still goes wrong in my case...

I want to show some HTML if a certain database field is NOT empty. So after following numerous options I got the following code:

<?
if ($remark!=="") 
{ 
    echo "<tr class=\"warning\"><td colspan=\"5\">REMARK: $item->remark </td></tr>";
} 
?>

But the code is generated in every case, also if the field is empty. Also, I got the following message: Notice: Undefined variable: remark in...

If the field is empty, nothing needs to happen.

Upvotes: 1

Views: 71

Answers (1)

pavel
pavel

Reputation: 27092

You used undefined variable in condition.

if ($item->remark !== "") 

Upvotes: 1

Related Questions