Try cf_querytoarray in the developer exchange. Then
you'll be able to have the number of fields and their
names.

http://devex.allaire.com/developer/gallery/
--- Clint Tredway <[EMAIL PROTECTED]> wrote:
> 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.


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
------------------------------------------------------------------------------
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