Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFIF question

Status
Not open for further replies.

websh

Technical User
Jan 8, 2002
13
US
My Nesting CFIF skills are a little rusty and I am looking for some help with this tag.

I am retrieving a name and address from a database where some addresses have a 2 line address and some a 3 line address. I want ColdFusion to output the address as it is written on snail mail (in the U.S.).

Here is what I am looking for:

<cfoutput query=&quot;queryname&quot; datasource=&quot;datasource&quot;>
#firstname# #mid_int# #lastname#<br>
#address1#<br>
#address2#<br> (if it exists)
#address3#<br> (if it exists)
#city#, #state# #postcode#
</cfoutput>

I am looking for the most efficient way to write this.

Any help is very much appreciated as pressed and on a deadline.

Thanks!

sh
 
Try this:

<cfoutput query=&quot;queryname&quot; datasource=&quot;datasource&quot;>
#firstname# #mid_int# #lastname#<br>
#address1#<br>
<cfif address2 IS NOT &quot;&quot;>#address2#<br></cfif>
<cfif address3 IS NOT &quot;&quot;>#address3#<br></cfif>
#city#, #state# #postcode#
</cfoutput>

Good luck!

 
Thanks for your prompt response!

In one of my attempts to write this, I used the code you wrote, however, I get the following results on some addresses:

John Doe
123 Main Street

Anytown, CA 99999

I don't want the extra empty line between the streetn address line and the city, state and zip code.

Any ideas?

Thanks again, sh
 
The code ran o.k. for me...I have an address database, too. The only think I can think of right now is this: are you sure you have the <br>'s before the </cfif>'s??
 
snix1,

Thanks, I got it to work. And yes, I did have my <br>'s inside my </cfif>'s.

Appreciate the help!

sh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top