To build the
4.
price
the previous step.
<!--- Build subclause for price--->
<cfif Form.priceValue GT "">
<cfif Form.priceOperator EQ "EQUALS">
<cfset WhereClause = WhereClause & " and price = " & form.priceValue>
<cfelseif Form.priceOperator EQ "GREATER">
<cfset WhereClause = WhereClause & " and price > " & form.priceValue>
<cfelseif Form.priceOperator EQ "SMALLER">
<cfset WhereClause = WhereClause & " and price < " & form.priceValue>
</cfif>
</cfif>
Save the file.
5.
Exercise 6: Testing the revised Trip Search Results page
In this exercise, you will verify that the
query.
To test the revised Trip Search Results page:
Open the tripsearchform.cfm page in the my_app directory in your browser.
1.
In the Departure Date drop-down list box, select Before, enter 1/1/1900 as the date (specify
2.
1900-1-1 on UNIX).
Select Smaller Than, and enter 0 for the price.
3.
Click the Search button.
4.
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 than the one presented here. However, this more
extensible approach is beyond the scope of this tutorial.
Summary
This lesson described how to build a search tool that dynamically builds a WHERE clause of the
SQL SELECT statement using
intact, you used the
In the next lesson
In the next lesson, you will build the Trip Detail page, which will display detailed information
about the currently selected trip.
WHERE subclause, enter the following code after the code you entered in
price
and
cfif
cfset
PreserveSingleQuotes
and
are now considered in the
departureDate
tags. To ensure that the SQL statement remains
CFML function.
Summary
83
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