74
Chapter 6: Lesson 2: Writing Your First ColdFusion Application
Exercise: enabling the departure and price criteria on the Trip Search
form
In this exercise you will modify the Trip Search Results page to add the criteria needed for the
departure and price query.
To enable the departure and price criteria:
1
In an editor, open the tripsearchresult.cfm page in the my_app directory, then locate the
following comment line:
<!--- Query returning search results --->
2
To build the
departureDate
WHERE subclause, enter the code in the following table
immediately following the comment line.
3
To build the
price
WHERE subclause, enter the following code after the code you entered in
step 2.
<!--- Build subclause for price--->
<cfif Form.priceValue GT "">
<cfif Form.priceOperator EQ "EQUALS">
<cfset WhereClause = WhereClause & " and price = " & form.priceValue>
<cfelseif Form.priceOperator EQ "GREATER">
<cfset WhereClause = WhereClause & " and price > " & form.priceValue>
<cfelseif Form.priceOperator EQ "SMALLER">
<cfset WhereClause = WhereClause & " and price < " & form.priceValue>
</cfif>
</cfif>
For
Enter this code
Windows users,
using the MS Access
database file
<!--- Build subclause for departureDate --->
<cfif Form.departureValue GT "">
<cfif Form.departureOperator EQ "EQUALS">
<cfset WhereClause = WhereClause & " and departureDate = " &
Form.departureValue>
<cfelseif Form.departureOperator EQ "AFTER">
<cfset WhereClause = WhereClause & " and departureDate > " &
Form.departureValue>
<cfelseif Form.departureOperator EQ "BEFORE">
<cfset WhereClause = WhereClause & " and departureDate < " &
Form.departureValue>
</cfif>
</cfif>
UNIX users, using the
PointBase database
file
<!--- Build subclause for departureDate --->
<cfif Form.departureValue GT "">
<cfif Form.departureOperator EQ "EQUALS">
<cfset WhereClause = WhereClause & " and departureDate = Date '" &
Form.departureValue & "'">
<cfelseif Form.departureOperator EQ "AFTER">
<cfset WhereClause = WhereClause & " and departureDate > Date '"
& Form.departureValue & "'">
<cfelseif Form.departureOperator EQ "BEFORE">
<cfset WhereClause = WhereClause & " and departureDate < Date '" &
Form.departureValue &
"'">
</cfif>
</cfif>
Summary of Contents for COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Page 1: ...Getting Started Building ColdFusion MX Applications...
Page 6: ...6 Contents...
Page 10: ......
Page 30: ...30 Chapter 2 CFML Basics...
Page 36: ...36 Chapter 3 Database Fundamentals...
Page 48: ......
Page 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Page 134: ...134 Index...