Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output all data from a query without specifying headers 2

Status
Not open for further replies.

jmcg

Technical User
Jun 30, 2000
223
GB
I have a query that is built dynamically from the user input determining what fields should be completed.first it determines that questions that should have been completed by the user:
Code:
<CFQUERY datasource="DeskScripts" name="ShowQuestions"> 
SELECT Questions.*
FROM Questions
WHERE Questions.UserrType = #User#
</CFQUERY>
It then creates a string list of the questions:
Code:
<CFOUTPUT query="ShowQuestions">
<CFSET jmQuery = jmQuery & "Scripts.#Reference#,">
</CFOUTPUT>
and then queries the results:
Code:
<CFQUERY datasource="DeskScripts" name="SACDetails"> 
SELECT Scripts.SAC, #jmQuery# DeskBase.Treatment
FROM Scripts INNER JOIN DeskBase ON Scripts.SAC = DeskBase.SAC
WHERE DeskBase.Treatment = '#jmTreatment# Touch'
</CFQUERY>
All fine so far and everything works.

What I now want to do it output that query to the page or to a file but cannot figure out how to do it without specifying each col header (depending on the user this is between 25 & 70 so has to e dynamic).
Any help much appreciated.
 
jmQuery is a list of the columns, correct? If so, something like this might work:
Code:
<cfoutput>
	<cfloop index="i" list="#jmQuery#">
		Name: #i# - Value: #SACDetails[i]# <br>
	</cfloop>
</cfoutput>
This is untested and off the top of my head, but it should give you the column name and value returned from the query.



Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
jmcg, you should start using cfqueryparam.

Code:
<CFQUERY datasource="DeskScripts" name="ShowQuestions"> 
SELECT Questions.*
FROM Questions
WHERE Questions.UserrType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#User#" maxlength="100">
</CFQUERY>


____________________________________
Just Imagine.
 
jmcg,

Code:
<table>
<cfoutput query="DeskScripts">
	<tr>
	<cfloop list="#DeskScripts.columnList#" index="col">
		<td>#DeskScripts[col][currentRow]#</td>
	</cfloop>
	</tr>
</cfoutput>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top