1 Reply Latest reply on Apr 20, 2008 9:03 AM by JR "Bob" Dobbs-qSBHQ2

    cf trim

    EugenT
      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. ...
        • 1. Re: cf trim
          JR "Bob" Dobbs-qSBHQ2 Level 3
          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.