User Guide

Table Of Contents
468 Chapter 20: Accessing and Retrieving Data
To query the table:
1.
Create a ColdFusion page with the following content:
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<cfquery name="EmpList" datasource="cfdocexamples">
SELECT FirstName, LastName, Salary, Contract
FROM Employee
</cfquery>
</body>
</html>
Note: Macromedia recommends that you create structured, reusable code by putting queries in
ColdFusion components; however, for simplicity, the examples in this chapter include the query in
the body of the ColdFusion page. For more information about using ColdFusion components, see
Chapter 10, “Building and Using ColdFusion Components,” on page 201.
2.
Save the page as emplist.cfm in the myapps directory under your web_root directory. For
example, the default path on a Windows computer would be:
C:\CFusionMX7\wwwroot\myapps\
3.
Enter the following URL in your web browser:
http://localhost/myapps/emplist.cfm
Only the header appears.
4.
View the source in the browser:
ColdFusion creates the EmpList data set, but only HTML and text return to the browser.
When you view the pages source, you see only HTML tags and the heading “Employee List.
To display the data set on the page, you must code tags and variables to output the data.