Programming instructions
66 Lesson 2 Writing Your First ColdFusion Application
Creating a dynamic web page
In the following exercises you will build a dynamic Trip Listing web page that is always 
current. The first exercise guides you through constructing a query to retrieve 
information from the database. In the second exercise, you will enhance the query to sort 
the query results and to display other pertinent trip information. 
For your convenience, the following figure shows the Compass Travel Trips table. You 
can refer to this table to verify the names of the columns you use in the queries in the 
exercises.
Exercise: building a query using SQL, cfquery, and cfoutput
Follow these steps to build a query that lists the current trips from the Compass Travel 
database.
To build  the query:
1 Open an editor and create a new ColdFusion page (.cfm). 
2 At the top of the file, enter the following code to dynamically retrieve the names of 
the current trips listed in the Compass Travel database:
<cfquery name="TripResult" datasource="compasstravel">
SELECT tripName FROM trips
</cfquery>
<html>
<head>
<title>Trip Listing</TITLE>
</head>
<body>
<h1>Trip List</h1>
<cfoutput query="TripResult">#tripName#<BR></cfoutput>
</body>
</html> 
3 Save the file as triplisting.cfm in the my_app directory.
4 View the triplisting.cfm page in a browser. The page lists all the trip names retrieved 
from Compass Travel database. 










