"post_golfer_form.cfm" page. Since your textboxes names are the golfers
IDs, then you can use the textbox value to adjust the purse and the name of
the textbox as the where clause. Like so:
<cfloop index="thefield" list="#form.fieldnames#">
<cfquery name="golfersupdate" datasource="#DSN#"
username="#db_username#" password="#db_password#">
update golfers
set golfer_purse = #evaluate("form.#thefield#")
where golfer_id = #thefield#
</cfquery>
</cfloop>
-----Original Message-----
From: Jillian Carroll [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 11, 2004 8:38 AM
To: CF-Talk
Subject: Insert dynamic form fields into a database
I've got a form that is made up of a dynamic list of form fields. How do I
write the SQL query so that it will loop over all of the fields to do the
insert?
My form:
<cfquery name="golfers" datasource="#DSN#" username="#db_username#"
password="#db_password#">
SELECT *
FROM golfers
ORDER BY
golfer_name
</cfquery>
<br />
<form name="team_info" action="" method="post">
<table border="0" cellpadding="1" cellspacing="0" width="98%"
align="center">
<tr>
<td class="tableheader" width="125">Golfer</td>
<td class="tableheader">Purse</td>
</tr>
<cfloop query="golfers">
<tr>
<td>#golfer_initial# #golfer_name#</td>
<td><input type="text" name="#golfer_id#" value="#golfer_purse#"
/></td>
</tr>
</cfloop>
<tr>
<td><input type="submit" value="Save Changes"></td>
</tr>
</table>
</form>
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

