Getting Information About Query Results - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 3: Querying a Database
When outputting the data itself, you define the variable name using the QUERY
attribute.
When outputting query properties variables, don't use the QUERY attribute;
instead, prefix the variable reference with the name of the query, for example,
EmpList.RecordCount
Columns must exist and be retrieved to the application in order to output their
values.
As with other attributes, surround the QUERY value with double quotes (").
As with any variables that you reference for output, surround column names
with pound signs (#) to tell ColdFusion to output the column's current values.
Add a <BR> tag to the end of the variable references so that ColdFusion will
start a new line for each row that is returned from the query.

Getting Information About Query Results

Each time you query a database with the CFQUERY tag, you get not only the data itself,
but also query properties, as described in the following table::
Query Properties
Property
RecordCount
ColumnList
CurrentRow
To output query data on your page:
1.
Return to
2.
Edit the file so that it appears as follows:
<HTML>
<HEAD>
<TITLE>Employee List</TITLE>
</HEAD>
<BODY>
<H1>Employee List</H1>
<CFQUERY NAME="EmpList" DATASOURCE="CompanyInfo">
</CFQUERY>
<CFOUTPUT QUERY="EmpList">
</CFOUTPUT>
.
Description
The total number of records returned by the query.
Returns a comma-delimited list of the query columns.
The current row of the query being processed by CFOUTPUT.
in Studio.
emplist.cfm
SELECT FirstName, LastName, Salary, Contract
FROM Employees
#FirstName#, #LastName#, #Salary#, #Contract#<BR>
27

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion 4.5

Table of Contents