Jump to content


Photo

Formatting Issue


  • Please log in to reply
2 replies to this topic

#1 WendyLady

WendyLady
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 10 June 2006 - 05:32 AM

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

#2 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 10 June 2006 - 05:42 AM

You have the right idea. Right after $address1, you will need an if statement to determine whether or not to display $address2.

<?php
...
echo($address1);
if($address2 != "")
{
    echo(', ' . $address2);
}
...
?>

Or something similar to that.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#3 WendyLady

WendyLady
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 10 June 2006 - 08:17 PM

Great! That is exactly what I was looking for. Thanks!

Wendy





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users