Summary
75
4
Verify that the
price
and
departureDate
are now considered in the query, as in step 4 in the
previous exercise:
a
Open the tripsearch.cfm page in the my_app directory in your browser.
b
In the Departure Date drop-down list box, select Before
,
enter 1/1/1900
as the date (specify
1900-1-1 on UNIX), and select Smaller Than 0 for the price
.
c
Click the Search button.
Because the departure date is considered in the query, there are no rows returned.
Note:
If you planned to use many more fields as search criteria, the approach used to add
departure date and price criteria to the Trip Search form is not the most elegant solution. A generic
routine to handle WHERE clause string construction based on specific data types could reduce
the code and be a more extensible solution then the one presented here. This more extensible
approach is beyond the scope of this tutorial, however.
Summary
This lesson described how to access a relational database using ColdFusion. You used the SQL
SELECT statement and the
cfquery
and
cfoutput
tags to display trip lists. You built a search
tool that dynamically builds a WHERE clause of the SQL SELECT statement using
cfif
and
cfset
tags. To ensure that the SQL statement remains intact, you used the
PreserveSingleQuotes
CFML function.
In the next lesson
In the next lesson, you will build the main navigation page for the Trip Maintenance application.
This page will display detail information about the currently selected trip. Additionally, it will
provide buttons to do trip maintenance and browsing through the trips table. You will also link
the trip search facility that you built in this lesson to the main page that you will build in the next.
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...