MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started page 73

Building coldfusion mx applications
Table of Contents

Advertisement

In later exercises, you will reference these columns when you build the SQL SELECT statement
for the
in the search action page.
cfquery
Understanding search query operators
Now that you have decided which columns can be queried (tripLocation, departureDate, and
price), you can build a simple form that lets the user enter values for each of these fields. If the
user enters a value (for example, Boston) for the tripLocation field and leaves the other two fields
blank, the search results page constructs the following SQL statement:
SELECT tripName, tripLocation, departureDate,
returnDate, price, tripID
FROM trips
WHERE tripLocation = 'Boston'
When you design the Search Criteria page, you must decide which operators to support for each
of the columns you can query. The operators that you use depend on the data type of the SQL
column.
For example, suppose the user wants a list of all the trips where the trip location begins with a
"B." SQL is well-suited for this type of query. Typical SQL string operators are equals, starts with,
contains, and ends with.
However, price is a numeric data type. The user can specify any of the following:
Price is 5000
Price less than 600
Price greater than 1500
Although many more operators are permissible, for simplification, you can use the following
operators for the Compass Travel columns that you can query:
Column to query
tripLocation
departureDate
price
Creating the Trip Search page
A simple design for a search criteria page presents an operator list and data entry field for each of
the columns that you can query. To create the search criteria page, you create an HTML form.
To create the search page:
Create a blank file.
1.
Note: If you are using Dreamweaver, select Dynamic page in the Category list and ColdFusion in
the Dynamic Page list.
Enter, or copy and paste, the following code in the blank file:
2.
<html>
<head>
Query operators
is, begins with
is, before, after
is, greater than, less than
Exercise 1: Creating the trip search form
73

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents