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:
In an editor, open the tripsearchresult.cfm page in the my_app directory, then locate the
1
following comment line:
<!--- Query returning search results --->
To build the
2
immediately following the comment line.
For
Windows users,
using the MS Access
database file
UNIX users, using the
PointBase database
file
To build the
3
price
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>
74
Chapter 6: Lesson 2: Writing Your First ColdFusion Application
WHERE subclause, enter the code in the following table
departureDate
Enter this code
<!--- 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>
<!--- 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>
WHERE subclause, enter the following code after the code you entered in
&
"'">
&
"'">
&
"'">
> " &
<
" &
Need help?
Do you have a question about the COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?
Questions and answers