Programming instructions
Enhancing the Trip Maintenance application 85
Exercise: building a Trip Detail page
Follow these steps to build a Trip Detail page.
To build a Trip Detail page:
1 Open your editor and create a new ColdFusion page. Remove any lines if your editor
adds.
2 To create a query to select a single trip from the Trips table, enter the following code:
<cfquery name="TripQuery" dataSource="compasstravel" maxRows=1>
SELECT tripID, tripName, tripDescription, tripLocation, departureDate,
returnDate, price, tripLeader, photo, baseCost, numberPeople, depositRequired
FROM TRIPS
<cfif IsDefined("URL.ID")>
WHERE tripID = #URL.ID#
</cfif>
</cfquery>
3 To output the results from the query, append the following cfoutput code after the
code you added in step 2.
<cfoutput query="TripQuery">
<img src="images/tripmaintenance.gif">
</cfoutput>
4 To display the data fields on the Trip Detail page, place the following code above the
</cfoutput> tag you added in step 3. Alternatively, you can copy this HTML code
from the tripdetail.txt file in the solutions directory.
<table>
<tr>
<td valign="top">Trip Name:
</td>
<td>#tripName#
</td>
</tr>
<tr>
<td valign="top">Description:
</td>
<td>#tripDescription#
</td>
</tr>
<tr>
<td valign="top">Location:
</td>
<td>#tripLocation#
</td>
</tr>
<tr>
<td valign="top">Departure Date:
</td>
<td>#departureDate#
</td>
</tr>
<tr>
<td valign="top">Return Date:
</td>