daryltoogood Posted March 21, 2010 Share Posted March 21, 2010 I have a page which gets email addresses from a MYSQL database and prints them with a ; between. echo $row_rs_units['train_email'].";"; Some entries don't have an email address, so only a ; is printed. How could I ignore the NULL values? I have tried the following, but it gives the same result as before if ($row_rs_units['train_email']==NULL) {echo "";} elseif ($row_rs_units['train_email']==!NULL) {echo $row_rs_units['train_email'].";";} Link to comment https://forums.phpfreaks.com/topic/195989-ignore-null-values/ Share on other sites More sharing options...
Bottyz Posted March 21, 2010 Share Posted March 21, 2010 try: if ($row_rs_units['train_email'] != NULL) { echo $row_rs_units['train_email'].";"; } theres no need for the echo nothing. Link to comment https://forums.phpfreaks.com/topic/195989-ignore-null-values/#findComment-1029465 Share on other sites More sharing options...
trq Posted March 21, 2010 Share Posted March 21, 2010 Just check the field is not empty. if (!empty($row_rs_units['train_email'])) { echo $row_rs_units['train_email'] . ";"; } Link to comment https://forums.phpfreaks.com/topic/195989-ignore-null-values/#findComment-1029467 Share on other sites More sharing options...
daryltoogood Posted March 22, 2010 Author Share Posted March 22, 2010 Thanks for the two different ways to achieve the same thing, they both work well! I have noticed that in the source code there is a large amount of white space between each email address. I assume that this white space will be ignored by the send email script that I am running? Link to comment https://forums.phpfreaks.com/topic/195989-ignore-null-values/#findComment-1029865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.