Using Html Tables To Layout Query Results - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 4: Retrieving and Formatting the Data You Want
Form variables for checkboxes and radio buttons generate errors on action
pages if nothing is selected for the form controls.

Using HTML Tables to Layout Query Results

You have displayed each row of data from the Employees table, but the information
was unformatted. You can use HTML tables to control the layout of information on the
page. In addition, you can use CFML functions to format individual pieces of data such
as dates and numeric values.
You can use HTML tables to specify how the results of a query appear on a page. To do
so, you put the CFOUTPUT tag inside the table tags. You can also use the HTML TH tag
to put column labels in a header row. To create a row in the table for each row in the
query results, put the TR block inside the CFOUTPUT tag.
To put the query results in a table:
1.
Return to the file
2.
Modify the page so that it appears as follows:
<HTML>
<HEAD>
<TITLE>Retrieving Employee Data Based on Criteia from Form</TITLE>
</HEAD>
<BODY>
<CFQUERY NAME="GetEmployees" DATASOURCE="CompanyInfo">
</CFQUERY>
<H4>Employee Data Based on Criteia from Form</H4>
4
<TABLE>
4
<TR>
4
<TH>First Name</TH>
4
<TH>Last Name</TH>
4
<TH>Salary</TH>
4
</TR>
<CFOUTPUT QUERY="GetEmployees">
4
<TR>
4
<TD>#FirstName#</TD>
4
<TD>#LastName#</TD>
4
<TD>#Salary#</TD>
4
</TR>
</CFOUTPUT>
4
</TABLE>
</BODY>
</HTML>
3.
Save the page as
emplist.cfm
SELECT FirstName, LastName, Salary
FROM Employees
WHERE LastName='#Form.LastName#'
actionpage.cfm
in Studio.
within the
directory.
myapps
37

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion 4.5

Table of Contents