Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cf trim

Guest
Apr 20, 2008 Apr 20, 2008
Hello,
Can somebody tell me if I'm right with this syntax :

I have these values in DB :
AL,AK,AZ,AR,CA,CO,CT,DE,DC,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY

and i want to put out the full name of state.

<cfquery name="getArtists" datasource="cfartgallery">
SELECT state
FROM Artists
</cfquery>

<cfoutput query="getArtists">
<cfif Trim(state) is "AL">Alabama</cfif>
<cfif Trim(state) is "AK">Alaska</cfif>
<cfif Trim(state) is "AZ">Arizona</cfif>
<cfif Trim(state) is "AR">Arkansas</cfif>
<cfif Trim(state) is "CA">California</cfif>
<cfif Trim(state) is "CO">Colorado</cfif>
<cfif Trim(state) is "CT">Connecticut</cfif>
<cfif Trim(state) is "DE">Delaware</cfif>
<cfif Trim(state) is "DC">District of Columbia</cfif>
<cfif Trim(state) is "FL">Florida</cfif>
</cfoutput> etc. ...
TOPICS
Advanced techniques
325
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 20, 2008 Apr 20, 2008
LATEST
Your code is synatically valid.

You may wish to consider an alternative to the repeated cfif tags you are using.

1. Add a state lookup table to your database and add the state name to your query such as:

SELECT A.state, S.State_Name
FROM Artists AS A INNER JOIN US_States AS S
ON ( A.State = S.Abbreviation )

2. Create a function in ColdFusion to do the lookup, see attached code.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources