MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 84

Table of Contents

Advertisement

64
3
4
<!-- Generate a query with statistical data for each department. -->
<cfquery dbtype = "query" name = "DeptSalaries">
SELECT
Dept_Name,
AVG(Salary) AS AvgByDept
FROM GetSalaries
GROUP BY Dept_Name
</cfquery>
<!--- Reformat the generated numbers to show only thousands --->
<cfloop index="i" from="1" to="#DeptSalaries.RecordCount#">
<cfset DeptSalaries.AvgByDept[i]=Round(DeptSalaries.AvgByDept[i]/
1000)*1000>
</cfloop>
<html>
<head>
<title>Employee Salary Analysis</title>
</head>
<body>
<h1>Employee Salary Analysis</h1>
<!--- Bar graph, from DeptSalaries Query of Queries --->
<cfgraph type="bar"
query="DeptSalaries"
valueColumn="AvgByDept"
itemColumn="Dept_Name">
</cfgraph>
<br>
</body>
</html>
Save the page as graphdata.cfm in myapps under the Web root directory. For
example, the directory path on your machine might be:
C:\Inetpub\wwwroot\myapps on Windows NT
Return to your browser and enter the following URL to view graphdata.cfm:
http://127.0.0.1/myapps/graphdata.cfm
Chapter 5 Graphing Data

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents