wilna Posted March 24, 2010 Share Posted March 24, 2010 Hi I have an address table, eg: memnr, name, adress1, adress2, adress3, postalcode, etc. In some cases the member only has entries in say adress1 & 2, now if I display the information it looks something like this: memnr = 1234 name = ABCD address1 = Street 1234 address2 = City address3 = postalcode = 1234 I do not want to display the emtpy line in address 3, my code looks like this: while ($row=mysql_fetch_assoc($result)) { $memnr=$row['xnr']; $namesurname=$row['surinit']; $a1=$row['address1']; $a2=$row['address2']; $a3=$row['address3']; $postalcode=$row['pocode']; echo $memnr; echo "<br>"; echo $namesurname; echo "<br>"; echo $a1; echo "<br>"; echo $a2; echo "<br>"; echo $a3; echo "<br>"; echo $postalcode; } Quote Link to comment https://forums.phpfreaks.com/topic/196360-empty-fields/ Share on other sites More sharing options...
premiso Posted March 24, 2010 Share Posted March 24, 2010 Use an if statement checking if empty? if (!empty($a3)) { echo $a3; echo "<br>" } Quote Link to comment https://forums.phpfreaks.com/topic/196360-empty-fields/#findComment-1031046 Share on other sites More sharing options...
wilna Posted March 25, 2010 Author Share Posted March 25, 2010 Thank you, just one more question. Does !empty mean empty or not empty? If I read the if statement correct it says if $a3 is not empty then echo it? Quote Link to comment https://forums.phpfreaks.com/topic/196360-empty-fields/#findComment-1031540 Share on other sites More sharing options...
premiso Posted March 25, 2010 Share Posted March 25, 2010 The ! before a statement, like above, indicates NOT. Quote Link to comment https://forums.phpfreaks.com/topic/196360-empty-fields/#findComment-1031656 Share on other sites More sharing options...
wilna Posted March 26, 2010 Author Share Posted March 26, 2010 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/196360-empty-fields/#findComment-1032082 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.