Solved

Looping through a table

Posted on 2003-11-11
4
218 Views
Last Modified: 2013-12-24
OK, I am almost there.

I am trying to loop through a table and disply the headers (I got that).

Then I am trying to loop through and write the records (I got that).

What I cant seem to do it create a <cfswitch> where I check if the value is in a certain column heading and do something...  See below...

<table border=1>
      <tr bgcolor="#E8E8E8">
            <CFLOOP list="#AllListings.columnlist#" index="column_name">
            <td><CFOUTPUT>#column_name#</cfoutput></td>
            </cfloop>
      </tr>
      <cfoutput query="AllListings" startrow="#StartRow_AllListings#" maxrows="#MaxRows_AllListings#">
      <tr>
      <cfloop list="#AllListings.columnlist#" index="column_Name">
      <td><nobr>
            <cfset strColName="#Ucase(Trim(column_Name))#">
            <cfswitch expression="strColName">
            <cfcase value="Listing">
            <a href="Listing.asp?ID=#evaluate(column_name)#">#evaluate(column_name)#</a>
            </cfcase>
            <cfdefaultcase>
            <cfif Len(evaluate(column_name)) gt "200">
                  #left(evaluate(column_name),"100")#...
            <cfelse>
                  <cfif Len(evaluate(column_name)) lt "1">
                        &nbsp;
                  <cfelse>
                        #evaluate(column_name)#
                  </cfif>
            <cfif>
            </cfdefaultcase>
      </cfswitch>      
      </nobr></td>
</cfloop>
</tr>
</cfoutput>
</table>
0
Comment
Question by:turbosig
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Author Comment

by:turbosig
ID: 9724212
PS, I am not trying to perform a <cfswitch> on the value of the column, I am trying to do it on the actual column name, and if it is in that column, then display a formated value.
0
 
LVL 10

Accepted Solution

by:
Mause earned 100 total points
ID: 9724444
I gues you forgot the # in cfswitch! now the value of the switch is "strColName" instead of the value of strColName you want

<cfswitch expression="#strColName#">

Let me know if this works
Mause
Mause
0
 
LVL 2

Assisted Solution

by:jonnygo55
jonnygo55 earned 25 total points
ID: 9724464
well first of all you'll want to put pounds around your cfswitch expression....
<cfswitch expression="#strColName#">

and I am not sure if case matters but if it does than if you are converting the strColName to uppercase then you should  
do <cfcase value="LISTING">

thats all I see off the top of my head...let us know if that works for you...
0
 
LVL 2

Author Comment

by:turbosig
ID: 9724812
Yup, that was it.  I spilt up the points.  

Mause did answer first.  But you were both correct, i forgot the #.

Thanks.

-I remain
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question