Jump to content

Archived

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

WendyLady

Formatting Issue

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

Share this post


Link to post
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--]

Share this post


Link to post
Share on other sites

×

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.