Programming instructions
Developing a search capability 75
<!--- Create Where clause for query from data entered thru search form --->
<cfset WhereClause = " 0=0 ">
<!--- Build subclause for trip location --->
<cfif Form.tripLocationValue GT "">
<cfif Form.tripLocationOperator EQ "EQUALS">
<cfset WhereClause = WhereClause & " and tripLocation = '" &
form.tripLocationValue & "'" >
<cfelse>
<cfset WhereClause = WhereClause & " and tripLocation like '" &
form.tripLocationValue & "%'" >
</cfif>
</cfif>
<!--- Query returning search results --->
<cfquery name="TripResult" datasource="compasstravel">
SELECT tripName, tripLocation, departureDate, returnDate, price, tripID
FROM trips
WHERE #PreserveSingleQuotes(WhereClause)#
</cfquery>
<html>
<head>
<title>Trip Maintenance - Search Results</title>
</head>
<body>
<img src="images/tripsearchresults.gif">
<table border="0" cellpadding="3" cellspacing="0">
<tr bgcolor="Gray">
<td>Trip Name
</td>
<td>Location
</td>
<td>Departure Date
</td>
<td>Return Date
</td>
<td>Price
</td>
</tr>
<cfoutput query="TripResult">
<tr>
<td>#tripName#
</td>
<td>#tripLocation#
</td>
<td>#departureDate#
</td>
<td>#returnDate#
</td>
<td>#price#
</td>
</tr>
</cfoutput>
</table>
</body