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 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. 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>"; } ?> 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 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
Archived
This topic is now archived and is closed to further replies.