Exercise 5: Enabling The Departure And Price Criteria On The Trip Search Form - MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

Verify that the other criteria (departure date and price) are not taken into consideration yet as
3.
follows:
Click the Back button in the browser to return to the Trip Search page.
a
In the Departure Date drop-down list box, select Before, enter 1/1/1900 as the date, and
b
select Smaller Than 0 for the price.
Either of these conditions would produce a results page with no rows.
Click the Search button.
c
The Trip Search Results page should be identical to the one in Step 2, because the code to
build the WHERE clause in the Trip Search Results page does not include departure date
and price.
Exercise 5: 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:
Open the gettrips.cfc file.
1.
In the getTripsFromForm method, position the pointer before the
2.
To build the
3.
following table immediately before the
For this database
(Windows users)
Microsoft Access
database file
(UNIX users)
PointBase database
file
82
Chapter 7: Lesson 4: Building Dynamic Queries
WHERE subclause, enter or copy and paste the code in the
departureDate
Enter this code
<!--- Build subclause for departureDate --->
<cfif Form.departureValue GT "">
<cfif Form.departureOperator EQ "EQUALS">
<cfset WhereClause = WhereClause & " and departureDate = " &
CreateODBCDate(Form.departureValue)>
<cfelseif Form.departureOperator EQ "AFTER">
<cfset WhereClause = WhereClause & " and departureDate
CreateODBCDate(Form.departureValue)>
<cfelseif Form.departureOperator EQ "BEFORE">
<cfset WhereClause = WhereClause & " and departureDate
CreateODBCDate(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>
code block:
cfquery
&
"'">
&
"'">
&
"'">
code block.
cfquery
> " &
<
" &

Advertisement

Table of Contents
loading

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents