I do this for debugging queries:

<table border="1">
        <tr>
                <cfloop list="#myquery.ColumnList#" index="i">
                        <td><cfoutput>#i#</cfoutput></td>
                </cfloop>
        </tr>
        <cfoutput query="myquery">
                <tr <cfif not CurrentRow mod 2>bgcolor="eeeeee"</cfif>>
                        <cfloop list="#myquery.ColumnList#" index="i">
                                <td>#Evaluate(i)#</td>
                        </cfloop>
                </tr>
        </cfoutput>
</table>

hope this helps..


-----Original Message-----
From: Clint Tredway [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 11, 2000 12:50 PM
To: '[EMAIL PROTECTED]'
Subject: Question(banging my head against a wal)


I am trying to build a dynamic browser based database utility. Is there a
way to output columns from a query when you don't know what the field names
are?
Here is what I am talking about:

I pass a cfm page a list of fields that I want to see all the records for. I
use the form name in my select statement,
then I loop through the form name to create my table header. Now I want to
display the values for the fields under the
header I created. 

what is the method to do this? Here is my code....

I use the form name in my select statement
<cfquery name="selecttable" datasource="#form.get_db#">
      Select #form.table# From #form.tablename# 
     </cfquery> 

then I loop through the form name to create my table header
     <table width="700" cellpadding="0" cellspacing="0" border="0">
      <tr class="header">
       <cfset fieldcount = 0>
      <cfloop list="#form.table#" index="curr_field">
       <cfset fieldcount = fieldcount + 1>
       <cfoutput><td>#curr_field#</td></cfoutput>
      </cfloop>
      <cfoutput>fieldcount: #fieldcount#</cfoutput>
      </tr>
      <cfset abc = 0>
      
Now I want to display the values for the fields under the header I created.

      <cfloop list="#selecttable.columnlist#" index="curr_col">
       <cfif abc IS 0>
        <tr>
       </cfif>
        <cfset abc = abc + 1>
           <td><cfoutput>#curr_col#</cfoutput></td>
       <cfif abc IS fieldcount>
        </tr>
        <cfset abc = 0>
       </cfif>
       </cfloop>
     </table>

This output is used for debugging purposes....
     <cfoutput query="selecttable">
      <cfloop list="#selecttable.columnlist#" index="curr_column">
       #curr_column#<br>
      </cfloop>
     </cfoutput>

What do I need to change/fix/get rid off for this to work. I can do this in
ASP with ADO, but I want this in CF.

Thanks for any help/suggestions.

Clint
----------------------------------------------------------------------------
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to