Programming instructions
76 Lesson 2 Writing Your First ColdFusion Application
Reviewing the code
The following table describes the code used to build the tripLocation WHERE 
subclause:
Note that the preceding code only builds the tripLocation subclause. In the following 
exercise you will add code for the other two queryable columns, departureDate and price.
Completing the Trip Search Results page 
In the following exercises you will test and modify tripsearchresults.cfm. In the first 
exercise, you will test the Trip Search Results page by entering criteria on the Trip Search 
form and inspecting the results. In the second exercise, you will finish the code to 
construct the complete WHERE clause for all three queryable columns from the Trip 
Search form.
Exercise: testing the Trip Search Results page
Follow these steps to test the Trip Search Results page:
1 Copy the tripsearch.cfm and tripsearchresult.cfm files from the solutions directory to 
the my_app directory.
2 View the tripsearch.cfm from the my_app directory in your browser and do the 
following:
a In the Trip Location drop-down list box select the Begins With option, and enter 
the value C in the text box.
b Click Search. 
Code Explanation
<cfset WhereClause = " 0=0 "> 
The cfset tag initializes the WhereClause 
variable to hold the WHERE clause to be 
constructed. The initial value is set to "0=0", 
so that the WHERE clause has at least one 
subclause in case the user enters no search 
criteria.
<cfif Form.tripLocationValue GT "">
The cfif tag tests to see if user entered 
anything in the Value input box for 
tripLocation criterion. 
SELECT tripName, tripLocation, 
departureDate, returnDate, price, tripID 
FROM trips
WHERE #PreserveSingleQuotes(WhereClause)#
SQL query to execute. 
PreserveSingleQuotes ColdFusion 
function ensures that quotation marks will 
passed to the database server as intended.










