Ask a Question related to Coldfusion Database Access, Design and Development.
-
ctlcal #1
Outputting Query Results with Unknown Column Names
I have been using this code to grab the column headers from a select *
statement. (I never know what table will be queried out of 12,000 or so. I want
to loop through the column headers and then the query results in to a web page
table.
<cfoutput>
<cfset colHeaderNames = ArrayToList(recordset1.getColumnList())/>
#colHeaderNames#
</cfoutput>
Is there a similar method or any suggestions for outputting the results of the
query - now that I know the column headers?
ctlcal Guest
-
CF Query Column Names Returned in UPPERCASE
My Flex application retrieves data from the database using Stored Procedures and Queries in CFCs. However, when I return the query object from the... -
counting column and getting column names
Im using an Access database that will probably be switched over to Oracle later, but I need to find out how to get the number of columns in an... -
query results accessed by column/ordinal position
Is there a way to access query results by column or ordinal position within the recordset? Something like #queryName#. -
Outputting query results to excel.. wierd!!
OK, this is different to my previous posting, so I thought it best to post another to save confusion. I am having some really wierd things... -
Query results don't display properly in results table.IGNORE PREVIOUS
:disgust; I need to display the results of a query. The query runs properly. My problem is having specific results display in specific locations in... -
jdeline #2
Re: Outputting Query Results with Unknown Column Names
If I understand correctly, you can do something like the code below.
<CFLOOP LIST="colHeaderNames" INDEX="i">
#Evaluate(i)#
</CFLOOP>
jdeline Guest
-
ctlcal #3
Re: Outputting Query Results with Unknown Column Names
Thanks for the suggestion, but trying that out it looped through the recordset but just outputted the columnheaders over and over - rather then the field values.
ctlcal Guest
-
paross1 #4
Re: Outputting Query Results with Unknown Column Names
Column names and query results.
Phil
<table>
<tr><cfloop list="#recordset1.ColumnList#" index="col" delimiters=",">
<th><cfoutput>#col#</cfoutput></th>
</cfloop></tr>
<cfoutput query="recordset1">
<tr><cfloop list="#recordset1.ColumnList#" index="col">
<td>#recordset1[col][CurrentRow]#</td></cfloop></tr>
</cfoutput>
</table>
paross1 Guest
-
vkunirs #5
Re: Outputting Query Results with Unknown Column Names
Hi
just give ## in side the <cfllop>
<CFLOOP LIST="#colHeaderNames#" INDEX="i">
vkunirs Guest
-
ctlcal #6
Re: Outputting Query Results with Unknown Column Names
Great suggestion - But then you lose the actual order of columns and get them back alphabetically, which is why I went with the code above.
ctlcal Guest
-
ctlcal #7
Re: Outputting Query Results with Unknown Column Names
jdeline and vkunirs - This worked great! Thanks for the help!
ctlcal Guest
-
paross1 #8
Re: Outputting Query Results with Unknown Column Names
I was unaware of the getColumnList() method so I have been dong it the "hard
way", which unfortunately, lists the columns alphabetically. I couldn't find
getColumnList() documented in LiveDocs, but nothing surprises me any more.
This other solution is great.
Phil
paross1 Guest
-
ctlcal #9
Re: Outputting Query Results with Unknown Column Names
The documentation for "getColumnList" is in the Dreamweaver API Live Docs.
ctlcal Guest
-
paross1 #10
Re: Outputting Query Results with Unknown Column Names
Thanks. Since I don't use Dreamweaver it makes sense that I haven't seen this.
Phil
paross1 Guest



Reply With Quote

