Whatever message this page gives is out now! Go check it out!
<cfoutput>
#Form.LastName#
</cfoutput><cfquery name="GetEmployees" datasource="cfdocexamples">
SELECTFirstName, LastName, Contract
FROM Employee
</cfquery><cfquery name="GetEmployees" datasource="cfdocexamples">
SELECT FirstName, LastName, Contract
FROM Employee
WHERE LastName = 'Smith'
</cfquery><cfquery name="GetEmployees" datasource="cfdocexamples">
SELECT FirstName, LastName, Salary
FROM Employee
WHERE LastName=<cfqueryparam value="#Form.LastName#"
CFSQLType="CF_SQL_VARCHAR">
</cfquery><html>
<head>
<title>Retrieving Employee Data Based on Criteria from Form</title>
</head>
<body>
<cfquery name="GetEmployees" datasource="cfdocexamples">
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>
<cfoutput query="GetEmployees">
#FirstName#
#LastName#
#Salary#<br>
</cfoutput>
<br>
<cfoutput>Contractor: #Form.Contractor#</cfoutput>
</body>
</html>Code | Description | |
| Queries the data source cfdocexamples and names the query GetEmployees. | |
SELECT FirstName, LastName, Salary
FROM Employee
WHERE LastName=<cfqueryparam value="#Form.LastName#" CFSQLType="CF_SQL_VARCHAR">Retrieves the FirstName, LastName, and Salary fields from the Employee table, but only if the value of the LastName field matches what the user entered in the LastName text box in the form on formpage.cfm. | ||
| Displays results of the GetEmployees query. | |
#FirstName#
#LastName#
#Salary#<br>Displays the value of the FirstName, LastName, and Salary fields for a record, starting with the first record, then goes to the next line. Keeps displaying the records that match the criteria you specified in the SELECT statement, followed by a line break, until you run out of records. | ||
| Closes the cfoutput block. | |
<br>
<cfoutput>Contractor: #Form.Contractor#
</cfoutput>Displays a blank line followed by the text "Contractor": and the value of the form Contractor check box. A more complete example would test to ensure the existence of the variable and would use the variable in the query. |
<cfif IsDefined("Form.Contractor")>
<cfoutput>Contractor: #Form.Contractor#</cfoutput>
</cfif><cfinput type="Text" name="FirstName" size="20" maxlength="35" required="Yes"> |
<input type="Text" name="FirstName" size="20" maxlength="35">
<input type="hidden" name="FirstName_required"><cfinput type="Text" name="FirstName" size="20" maxlength="35" required="Yes"
message="You must enter your first name."><input type="hidden" name="FirstName_required"
value="You must enter your first name.">