Chapter 4: Retrieving and Formatting the Data You Want
37
•
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
emplist.cfm
in Studio.
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">
SELECT FirstName, LastName, Salary
FROM Employees
WHERE LastName=’#Form.LastName#’
</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
actionpage.cfm
within the
myapps
directory.
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...