
98
Chapter 6 Making Variables Dynamic
Creating the action page
After you create the input form, you can create the action page to process the user’s
request. This action page determines where the user entered search criteria and
searches based only on those criteria.
To create the action page:
1
Create a new application page in ColdFusion Studio.
2
Enter the following code:
<html>
<head>
<title>Get Employee Data</title>
</head>
<body>
<cfquery name="GetEmployees" datasource="CompanyInfo">
SELECT *
FROM Employee
WHERE
<cfif #form.firstname# is not "">
Employee.FirstName LIKE ’#form.FirstName#%’ AND
</cfif>
<cfif #form.lastname# is not "">
Employee.LastName LIKE ’#form.LastName#%’ AND
</cfif>
<cfif #form.salary# is not "">
Employee.Salary >= #form.Salary# AND
</cfif>
<cfif isdefined("Form.Contract")>
Employee.Contract = ’Yes’ AND
<cfelse>
Employee.Contract = ’No’ AND
</cfif>
0=0
</cfquery>
<h3>Employee Data Based on Criteria from Form</h3>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Salary</th>
<th>Contractor</th>
</tr>
<cfoutput query="GetEmployees">
<tr>
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...