[thelist] CF (SQL?): query.columnlist

Judah McAuley judah at alphashop.com
Fri May 18 17:14:20 CDT 2001


So, I am trying to write an "elegant" form.  i.e., I don't like typing 
alot.  I'm using Cold Fusion and querying the database to get the list of 
columns in a table.  I then loop over the list and create a form that has 
all the entries I want.  In the database, the fields are in the order I 
want to display them on the page.  Most everything works as expected, but 
the problem is that the query column list comes out in alphabetical 
order.  I'm not quite sure whether SQL is returning the list alphabetically 
or wether CF is changing the sort order when it turns it into a list.  Does 
anyone have an idea about an SQL or CF hack that will return the column 
list to me in the order I created them in the database?

Applicable code snippets are as follows:

<cfquery name="get_profile_vars" datasource="#application.datasource#" 
dbtype="#application.dbtype#">
	SELECT *
	FROM member_profile
	WHERE 1 = 0
</cfquery>

<!--- The list of variables that aren't simple text inputs --->

<cfset textarea_type = "description, specialty_description">
<cfset file_type = "img_src">
<cfset hidden_type = "id">
<cfset no_display = "member_id, date_added, profile_number">

<cfoutput>
<form 
action="#cgi.script_name#?fuseaction=#fuseaction#&subfuse=#subfuse#&#vars#" 
method="post" enctype="multipart/form-data">
<cfloop index="current_field" list="#get_profile_vars.columnlist#">
	<cfif ListContainsNoCase(textarea_type,current_field)>
		#current_field# <textarea cols=23 rows=5 name="#current_field#"></textarea>
	<cfelseif ListContainsNoCase(hidden_type,current_field)>
		<input type="hidden" name="#current_field#" value="">
	<cfelseif ListContainsNoCase(file_type,current_field)>
		#current_field# <input type="file" name="#current_field#">
	<cfelseif ListContainsNoCase(no_display,current_field)>
				
	<cfelse>
		#current_field# <input type="text" name="#current_field#" size="25">
	</cfif>
</cfloop>
</cfoutput>

TIA, Judah 





More information about the thelist mailing list