Solved

Looping through a table

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

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

18 Experts available now in Live!

Get 1:1 Help Now