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.



Attribute Reference for the cfoutput tag


Required: No
Name of cfquery from which to draw data for output section.


Required: No
Query column to use to group sets of records. Eliminates
adjacent duplicate rows when data is sorted. Use if you
retrieved a record set ordered on one or more a query
columns. For example, if a record set is ordered on
"Customer_ID" in the cfquery tag, you can group the output
on "Customer_ID."


Required: No
Whether to consider the case in grouping rows.


Required: No
Row from which to start output.


Required: No
Maximum number of rows to display.


Required: No
CF 2016+ Lucee 5.1+ When set applies an encoder to all variables to prevent XSS. For example if you specify html each variable will be wrapped by a call to the encodeForHTML function. Values:
  • html
  • htmlattribute
  • javascript
  • css
  • xml
  • xmlattribute
  • url
  • xpath
  • ldap
  • dn

Examples sample code using the cfoutput tag

Simple Tag Example

<cfoutput>Some text and a #encodeForHTML(variable)#</cfoutput>

Loop over a query

Loops over each row of the query specified and outputs the result.

<cfoutput query="news">

Using the encodeFor attribute

CF 2016+ Lucee 5.1+ By specifying encodefor="html" each varaible is encoded using the encodeForHTML function before it is output.

<cfoutput query="news" encodefor="html">

Using the group attribute

Creates a dummy query food, with columns name and type. Then outputs the food by grouping by the type.

<cfset food = queryNew("name,type",
    [ {name:"Apple",type:"Fruit"}, 
      {name:"Chicken",type:"Meat"} ])>
<cfoutput query="food" group="type">

Fork me on GitHub