User Guide

Table Of Contents
618 Chapter 26: Introduction to Retrieving and Formatting Data
To put the query results in a table:
1.
Open the ColdFusion actionpage.cfm page in your editor.
2.
Modify the page so that it appears as follows:
<html>
<head>
<title>Retrieving Employee Data Based on Criteria from Form</title>
</head>
<body>
<cfquery name="GetEmployees" datasource="cfdocexamples">
SELECT FirstName, LastName, Salary
FROM Employee
WHERE LastName=<cfqueryparam value="#Form.LastName#"
CFSQLType="CF_SQL_VARCHAR">
</cfquery>
<h4>Employee Data Based on Criteria from Form</h4>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Salary</th>
</tr>
<cfoutput query="GetEmployees">
<tr>
<td>#FirstName#</td>
<td>#LastName#</td>
<td>#Salary#</td>
</tr>
</cfoutput>
</table>
<br>
<cfif IsDefined("Form.Contractor")>
<cfoutput>Contractor: #Form.Contractor#</cfoutput>
</cfif>
</body>
</html>
3.
Save the page as actionpage.cfm in the myapps directory.
4.
View the formpage.cfm page in your browser.
5.
Enter Smith in the Last Name text box and submit the form.
The records that match the criteria specified in the form appear in a table.