Solved

Looping through a table

Posted on 2003-11-11
4
195 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now