User Guide

Table Of Contents
Working with queries and data 619
Reviewing the code
The following table describes the highlighted code and its function:
Formatting individual data items
You can format individual data items. For example, you can format the salary data as monetary
values. To format the salary data using the dollar format, you use the CFML function
DollarFormat(number).
To change the format of the Salary:
1.
Open the file actionpage.cfm in your editor.
2.
Change the following line:
<td>#Salary#</td>
to
<td>#DollarFormat(Salary)#</td>
3.
Save the page.
Building flexible search interfaces
One option with forms is to build a search based on the form data. For example, you could use
form data as part of the WHERE clause to construct a database query.
To give users the option to enter multiple search criteria in a form, you can wrap conditional logic
around a SQL AND clause as part of the WHERE clause. The following action page allows users
to search for employees by department, last name, or both.
Note: ColdFusion MX provides the Verity search utility that you can also use to perform a search. For
more information, see Chapter 24, “Building a Search Interface,” on page 547.
Code Description
<table>
Puts data into a table.
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Salary</th>
</tr>
In the first row of the table, includes three columns, with the
headings: First Name, Last Name, and Salary.
<cfoutput query="GetEmployees">
Tells ColdFusion to display the results of the GetEmployees
query.
<tr>
<td>#FirstName#</td>
<td>#LastName#</td>
<td>#Salary#</td>
</tr>
For each record in the query, creates a new row in the table,
with three columns that display the values of the FirstName,
LastName, and Salary fields of the record.
</cfoutput>
Ends the output region.
</table>
Ends the table.