Ell20 Posted October 29, 2007 Share Posted October 29, 2007 Hey guys, Im trying to display some information in a while loop however one of the bits of data is optional so I dont want the heading to be displayed if there is no data in the variable. Here is my code at the moment but it dosent appear to be working: <?php if(isset($row['description'])) { echo "<b>Team Description: </b>"; echo $row['description']; echo "<br>"; } ?> Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/75280-solved-only-display-if-variable-is-set/ Share on other sites More sharing options...
Orio Posted October 29, 2007 Share Posted October 29, 2007 Well obviously it's set, but probably just empty... use !empty() instead of isset() Orio. Quote Link to comment https://forums.phpfreaks.com/topic/75280-solved-only-display-if-variable-is-set/#findComment-380735 Share on other sites More sharing options...
Dragen Posted October 29, 2007 Share Posted October 29, 2007 <?php if(!empty($row['description'])) { echo "<b>Team Description: </b>"; echo $row['description']; echo "<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75280-solved-only-display-if-variable-is-set/#findComment-380736 Share on other sites More sharing options...
Ell20 Posted October 29, 2007 Author Share Posted October 29, 2007 Thanks for your help, spot on as usual! Elliot Quote Link to comment https://forums.phpfreaks.com/topic/75280-solved-only-display-if-variable-is-set/#findComment-380738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.