MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 568

Developing coldfusion mx applications
Table of Contents

Advertisement

<body>
<cfquery name="GetEmployees" datasource="CompanyInfo">
SELECT FirstName, LastName, Salary
FROM Employee
WHERE LastName=<cfqueryparam value="#Form.LastName#"
CFSQLType="CF_SQL_VARCHAR">
</cfquery>
<h4>Employee Data Based on Criteria from Form</h4>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Salary</th>
</tr>
<cfoutput query="GetEmployees">
<tr>
<td>#FirstName#</td>
<td>#LastName#</td>
<td>#Salary#</td>
</tr>
</cfoutput>
</table>
<br>
<cfif IsDefined("Form.Contractor")>
<cfoutput>Contractor: #Form.Contractor#</cfoutput>
</cfif>
</body>
</html>
Save the page as actionpage.cfm within the myapps directory.
3
View formpage.cfm in your browser.
4
Enter Smith in the Last Name text box and submit the form.
5
The records that match the criteria specified in the form appear in a table.
6
Reviewing the code
The following table describes the highlighted code and its function:
Code
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Salary</th>
</tr>
<cfoutput query="GetEmployees">
<tr>
<td>#FirstName#</td>
<td>#LastName#</td>
<td>#Salary#</td>
</tr>
</cfoutput>
</table>
568
Chapter 26: Retrieving and Formatting Data
Description
Puts data into a table.
In the first row of the table, includes three columns, with the
headings: First Name, Last Name, and Salary.
Gets ready to display the results of the GetEmployees query.
Creates a new row in the table, with three columns. For a
record, puts the value of the FirstName field, the value of the
LastName field, and the value of the Salary field.
Keeps getting records that matches the criteria, and displays
each row in a new table row until you run out of records.
End of table.

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents