– Common Function Library Project


Last updated June 9, 2011


Jared Rypka-Hauer

Version: 2 | Requires: CF8 | Library: UtilityLib

This UDF takes a query as an argument and dumps out the contents of the query in a table, columns in TH tags and data in TD tags, for the simple purpose of examining the data in a page. Not intended for production use, it's handy for the beginning stages of laying out a page based on someone else's query or dumping the contents of a cfdirectory or cfpop call in situations where significant formatting is not necessary.

Return Values:
Returns a string.


<cfdirectory action="list" directory="#expandPath('.')#" name="dirList" />


Name Description Required
queryData Query to display. Yes

Full UDF Source:

 Simple table-based datadump from any query
 @param queryData 	 Query to display. (Required)
 @return Returns a string. 
 @author Jared Rypka-Hauer ( 
 @version 2, June 9, 2011 
<cffunction name="queryToTableDump" access="public" returntype="string" output="false">
	<cfargument name="queryData" type="query" required="true" />
	<cfset var theQuery = arguments.queryData>
	<cfset var columns = arraytolist(theQuery.getMeta().getColumnLabels())>
	<cfset var theResults = "">
	<cfset var c = "">
	<cfset var i = "">
	<cfsavecontent variable="theResults">
			<table border="1" cellpadding="0" cellspacing="0" align="left">
			<cfloop list="#columns#" index="c">
			<cfloop from="1" to="#theQuery.recordCount#" index="i">
				<tr><cfloop list="#columns#" index="c">
					<td><cfif len(theQuery[c][i])>#theQuery[c][i]#<cfelse> </cfif></td></cfloop>
	<cfreturn theResults />
blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson