![MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual Download Page 128](http://html1.mh-extra.com/html/macromedia/coldfusion-5-developing/coldfusion-5-developing_develop-manual_3293641128.webp)
108
Chapter 7 Updating Your Database
Reviewing the code
The following table describes the code and its function:
Code
Description
<cfquery name="GetRecordtoUpdate"
datasource="CompanyInfo">
SELECT *
FROM Employee
WHERE Emp_ID = #URL.Emp_ID#
</cfquery>
Query the CompanyInfo data source
and return the records in which the
employee ID matches what was
entered in the URL that called this
page.
<cfoutput query="GetRecordtoUpdate">
Make the results of the
GetRecordtoUpdate query available
as variables in the form created on
the next line.
<form action="updateaction.cfm"
method="Post">
Create a form whose variables will
be processed on the
updateaction.cfm action page.
<input type="Hidden" name="Emp_ID"
value="#Emp_ID#"><br>
Use a hidden input field to pass the
employee ID to the action page.
First Name:
<input type="text" name="FirstName"
value="#FirstName#"><br>
Last Name:
<input type="text" name="LastName"
value="#LastName#"><br>
Department Number:
<input type="text" name="Dept_ID"
value="#Dept_ID#"><br>
Start Date:
<input type="text" name="StartDate"
value="#StartDate#"><br>
Salary:
<input type="text" name="Salary"
value="#Salary#"><br>
Populate the fields of the update
form. This example does not use any
ColdFusion formatting functions to
“clean up” the form. As a result, the
start dates look like 1985-03-12
00:00:00 and the salaries do not
have dollar signs or commas. The
user can replace the information in
any field using any valid input format
for the data.
Contractor:
<cfif #Contract# IS "Yes">
<input type="checkbox" name="Contract"
checked>Yes<br>
<cfelse>
<input type="checkbox" name="Contract">
Yes <br>
</cfif>
<br>
<input type="Submit" value="Update
Information">
</form>
</cfoutput>
The Contractor field needs special
treatment because a check box
displays and sets its value. Use the
cfif
structure to put a check mark in
the check box if the Contract field
value is Yes, and leave the box
empty otherwise.
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 ...