
Enhancing the Trip Maintenance application
81
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 that 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>
<td>#returnDate#
</td>
</tr>
<tr>
Содержание COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 30: ...30 Chapter 2 CFML Basics...
Страница 36: ...36 Chapter 3 Database Fundamentals...
Страница 48: ......
Страница 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Страница 134: ...134 Index...