![MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual Download Page 117](http://html1.mh-extra.com/html/macromedia/coldfusion-5-developing/coldfusion-5-developing_develop-manual_3293641117.webp)
Dynamic SQL
97
Creating the input form
First, you need to create an input form, which asks for information about several
fields in the Employee table. To search for data based on only the fields the user
enters in the form, you use
cfif
statements in the SQL statement.
To create the input form:
1
Create a new application page in ColdFusion Studio.
2
Enter the following code:
<html>
<head>
<title>Input form</title>
</head>
<body>
<!--- Query the Employee table to be able to populate the form --->
<cfquery name="AskEmployees" datasource="CompanyInfo">
SELECT
FirstName,
LastName,
Salary,
Contract
FROM Employee
</cfquery>
<!--- define the action page in the form tag. The form variables will
pass to this page when the form is submitted --->
<form action="getemp.cfm" method="post">
<!-- text box -->
<p>First Name: <input type="Text" name="FirstName" size="20"
maxlength="35"><br>
Last Name: <input type="Text" name="LastName" size="20"
maxlength="35"><br>
Salary: <input type="Text" name="Salary" size="10" maxlength="10">
</p>
<!-- check box -->
<p>Contractor? <input type="checkbox" name="Contract" value="Yes"
>Yes if checked
</p>
<!-- reset button -->
<input type="reset" name="ResetForm" value="Clear Form">
<!-- submit button -->
<input type="submit" name="SubmitForm" value="Submit">
</form>
</body>
</html>
3
Save the page as
askemp.cfm
.
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...