Solved

Looping through a table

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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…
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: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 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