Builds a table in a ColdFusion 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. See Usage for information about using the cfcol
tag with the cftable
tag.
<cftable query = "query_name" maxRows = "maxrows_table" colSpacing = "number_of_spaces" headerLines = "number_of_lines" HTMLTable border colHeaders startRow = "row_number"> </cftable>
cfcol,
cfoutput,
cfcontent,
cfprocessingdirective,
cflog,
cftable
Attribute |
Description |
---|---|
query |
Required. Name of the cfquery from which to draw data. |
maxRows |
Optional. Maximum number of rows to display in the table. |
colSpacing |
Optional. Number of spaces to insert between columns (default is 2). |
headerLines |
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). |
HTMLTable |
Optional. Renders the table as an HTML 3.0 table. |
border |
Optional. Adds a border to the table. Use only when you specify the HTMLTable attribute for the table. |
colHeaders |
Optional. Displays headers for each column, as specified in the cfcol tag. |
startRow |
Optional. Specifies the query row from which to start processing. |
You can use the cfcol tag to align the data in the table, specify the width of each column, and provide column headers.
Note
|
<!--- This example shows the use of cfcol and cftable to align information returned from a query ---> <!--- This query selects employee information from the cfsnippets datasource ---> <cfquery name = "GetEmployees" dataSource = "cfsnippets"> SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department FROM Employees </cfquery> <html> <head> <title>cftable Example</title> </head> <body> <H3>cftable Example</H3> <!--- Note the use of the HTMLTable attribute to display the cftable as an HTML table, rather simply as PRE formatted information ---> <cftable query = "GetEmployees" startRow = "1" colSpacing = "3" HTMLTable> <!--- each cfcol tag sets the width of a column in the table, as well as specifying the header information and the text/CFML with which to fill the cell ---> <cfcol header = "<B>ID</B>" align = "Left" width = 2 text = "#Emp_ID#"> <cfcol header = "<B>Name/Email</B>" align = "Left" width = 15 text = "<a href = 'mailto:#Email#'>#FirstName# #LastName#</A>"> <cfcol header = "<B>Phone Number</B>" align = "Center" width = 15 text = "#Phone#"> </cftable> </body> </html>