Jump to content

Formatting Issue


WendyLady

Recommended Posts

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, address2
city, state, zip

But if they have only entered the first line & the second line is empty, I don't want it to print:

address1,
city, state, zip

So 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 nothing

Such 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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.