UPDATE golfers
SET golfer_purse = '#form[thefield]#'
WHERE golfer_id = #thefield#

> -----Original Message-----
> From: Jillian Carroll [mailto:[EMAIL PROTECTED]
> Sent: donderdag 11 maart 2004 15:12
> To: CF-Talk
> Subject: RE: Insert dynamic form fields into a database -
> More Help Needed
>
> Okay, I'm an idiot this morning.
>
> I don't understand what I'm supposed to be substituting.
>
> My code:
>
> <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 = #form.#
> </cfquery>
> </cfloop>
>
> This needs to be populated from:
>
> <input type="text" name="#golfer_id#" value="#golfer_purse#" />
>
> Can this even work?
>
> --
> Jillian
>
> -----Original Message-----
> From: Hagan, Ryan Mr (Contractor ACI) [mailto:[EMAIL PROTECTED]
> Sent: March 11, 2004 7:46 AM
> To: CF-Talk
> Subject: RE: Insert dynamic form fields into a database
>
>
> All you need to do is loop through your form collection on the
> "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]

Reply via email to