System information

Exercise 4: Testing the Trip Search Results page 81
The preceding code only builds the tripLocation subclause. In the following exercise, you will add
code for the other two columns that you can query, departureDate and price.
Exercise 4: Testing the Trip Search Results page
In this exercise, you will test the tripsearchresults.cfm page. First, you will test the Trip Search
Results page by entering criteria on the Trip Search form and inspecting the results. Next, you will
finish the code to construct the complete WHERE clause for all three columns that you can
query from the Trip Search form.
To test the Trip Search Results page:
1.
View the tripsearchform.cfm page from the my_app directory in your browser and do the
following:
a
In the Trip Location drop-down list, select the Begins With option, and enter the value C in
the text box.
b
Click Search.
The Trip Results page displays several entries, as follows:
c
Notice in the Trip Results page that only one trip has a trip location of China.
d
Click the Back button in your browser to return to the Trip Search page.
2.
In the Trip Location drop-down list of the Trip Search page, select the Is option, enter the value
China, and then click Search.
The Trip Search Results page displays only one entry for the trip to China in the HTML table.
<cfif Form.tripLocationValue GT "">
The
cfif tag tests to see if the user entered anything
in the Value input field for tripLocation criterion.
SELECT tripName, tripLocation,
departureDate, returnDate, price, tripID
FROM trips
WHERE #PreserveSingleQuotes(WhereClause)#
SQL query to execute. The PreserveSingleQuotes
function ensures that quotation marks are passed to
the database server as intended.
Code Explanation