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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output table values

Status
Not open for further replies.

cleanair4me

Technical User
May 16, 2008
61
I would like to know if there is something where I can automatically output all fields from one table so I dont have to manually put in each field name:
Code:
<cfquery name = "myQuery" datasource = "mydsn">
select * from tableOne
</cfquery>

<cfoutput query="myQuery">
#city#<br>
#state#<br>
#county#<br>
#country#<br>
#continent#<br>
</cfoutput>

Is there a dynamic array or ColdFusion method that can automatically output all the values from one table?
 
Try this:
Code:
<cfquery name = "myQuery" datasource = "mydsn">
select * from tableOne
</cfquery>
<cfoutput>
	<cfset variables.rowCount = 0>
	<cfloop query="myQuery">
		<cfset variables.rowCount = variables.rowCount + 1>
		<cfloop list="#myQuery.columnList#" index="variables.columnName">
			<cfset variables.temp = myQuery[variables.columnName][variables.rowCount]>
			#variables.columnName# = #variables.temp#<br />
		</cfloop>
		<hr>
	</cfloop>
</cfoutput>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top