Displays output that can contain the results of processing CFML variables and functions. You can use the query
attribute to loop over the result set of a database query.
<cfoutput>
writeOutput()
true
false
html
each variable will be wrapped by a call to the encodeForHTML
function.
html
htmlattribute
javascript
css
xml
xmlattribute
url
xpath
ldap
dn
<cfoutput>Some text and a #encodeForHTML(variable)#</cfoutput>
Loops over each row of the query specified and outputs the result.
<cfoutput query="news">
<h2>#encodeForHTML(news.headline)#</h2>
<p>#encodeForHTML(news.byline)#</p>
</cfoutput>
Loops over 10 rows of the query specified starting from row 5 and outputs the result.
<cfoutput query="news" startrow="5" maxrows="10">
<h2>#encodeForHTML(news.headline)#</h2>
<p>#encodeForHTML(news.byline)#</p>
</cfoutput>
CF 2016+ Lucee 5.1+ By specifying encodefor="html"
each variable is encoded using the encodeForHTML
function before it is output.
<cfoutput query="news" encodefor="html">
<h2>#news.headline#</h2>
<p>#news.byline#</p>
</cfoutput>
Creates a dummy query food
, with columns name
and type
. Then outputs the food by grouping by the type.
<cfset food = queryNew("name,type",
"varchar,varchar",
[ {name:"Apple",type:"Fruit"},
{name:"Orange",type:"Fruit"},
{name:"Chicken",type:"Meat"} ])>
<cfoutput query="food" group="type">
<h2>#type#</h2>
<ul>
<cfoutput><li>#name#</li></cfoutput>
</ul>
</cfoutput>
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.