Builds a table in a CFML page.

Use the <cfcol> tag to define table column and row characteristics.

The cftable tag renders data either as preformatted text, or, with the HTMLTable attribute, as an HTML table.

Use cftable to create tables if you don't want to write HTML table tag code, or if your data can be well presented as preformatted text.

This tag must have a body.

This tag is also supported within <cfscript>

<cftable query=string maxrows=number colspacing=number headerlines=number htmltable=boolean border=boolean colheaders=boolean startrow=number ><!--- body ---></cftable>
Attribute Description
string, required

Name of the cfquery from which to draw data.

number, optional

Maximum number of rows to display in the table.

number, optional

Number of spaces to insert between columns 'default is 2'.

number, optional

Number of lines to use for the table header. The default is 2, which leaves one line between the headers and the first row of the table.

boolean, optional

Renders the table as an HTML 3.0 table.

boolean, optional

Adds a border to the table. Use only when you specify the HTMLTable attribute for the table.

boolean, optional

Displays headers for each column, as specified in the cfcol tag.

number, optional

Specifies the query row from which to start processing.


<cfset data = queryNew("id,name,age", "integer,varchar,integer", [
<cfquery name="qryData" dbtype="query">
    SELECT *
    FROM data
<cftable query="qryData" startRow="1" colSpacing="3"  border=true  HTMLTable colHeaders>
    <cfcol header="<b>Id</b>" align="Left" width="15" text="#id#">
    <cfcol header="<b>Name</b>" align="Left" width="15" text="#name#">
    <cfcol header="<b>Age</b>" align="Left" width="15" text="#age#">

See also