Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Looping through a table

Posted on 2003-11-11
4
Medium Priority
?
227 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 400 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 100 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

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

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

What You Need to Know when Searching for a Webhost Provider
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

721 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