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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.