WendyLady Posted June 10, 2006 Share Posted June 10, 2006 Hi, all -- I have a question that is purely for formatting, but I'm not sure how to even search for this, or how to call things.I'm dealing with a database where users' contact information will be returned. I have two fields for address: address1 and address2. An example is that if the person has entered two address lines, I want it to print:address1, address2city, state, zipBut if they have only entered the first line & the second line is empty, I don't want it to print:address1, city, state, zipSo I think I need to write a little function for each formatting issue that would say, for example,if NOT NULL . . then echo ", address2""else do nothingSuch a silly thing -- but I'm not sure how to start. There are several of these that pose a problem. Can anyone point me in the right direction, even just to tell me how to search for help?Thank you!Wendy Link to comment https://forums.phpfreaks.com/topic/11636-formatting-issue/ Share on other sites More sharing options...
jeremywesselman Posted June 10, 2006 Share Posted June 10, 2006 You have the right idea. Right after $address1, you will need an if statement to determine whether or not to display $address2.[code]<?php...echo($address1);if($address2 != ""){ echo(', ' . $address2);}...?>[/code]Or something similar to that.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Link to comment https://forums.phpfreaks.com/topic/11636-formatting-issue/#findComment-43930 Share on other sites More sharing options...
WendyLady Posted June 10, 2006 Author Share Posted June 10, 2006 Great! That is exactly what I was looking for. Thanks!Wendy Link to comment https://forums.phpfreaks.com/topic/11636-formatting-issue/#findComment-44097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.