Hi Russ,

Assuming your field names are the same for each record, you will get a list
of data items when you submit the form, as in:

form.myId = 1,4,5,6,7
form.firstName=jeff,tom,steve,brad,jim
form.age=22,34,54,27,31

Now, all you need to do is loop over the myID list, and use basic list
functions to get at the data in your form submission

<!--- initialize a loop counter --->
<cfset j = 1>

<!--- loop over the list of record ID's in form.myID --->
<cfloop list="#form.myId#" index="ii">

        <cfquery name="myUpdate" datasource="myDatasource">
        UPDATE mytable
        SET     firstName = '#ListGetAt(form.firstname, j)#',
                age = #ListGetAt(form.age, j)#
        WHERE myId = #ii#
        </cfquery>
        <!--- increment the loop counter - next time through, j will equal 2, so
the list
                functions will grab the 2nd element in your list(s) --->
        <cfset j = j + 1>

</cfloop>


That should get you started.

-----Original Message-----
From: Russ [mailto:[EMAIL PROTECTED]
Sent: Saturday, February 22, 2003 12:30 PM
To: CF-Talk
Subject: SOT: Updating Multiple Records


Hello,

I apologize for being OT here, but I'm hitting a brickwall.  I've built
a page that displays several records--all of which can be edited and/or
turned on or turned off from a display perspective (editable textbox and
checkbox).

Unfortunately, my SQL experience doesn't lend to me being able to figure
out how to loop through all the IDs of the fields I've just displayed
and then update them.

I'm running on RH 7.2 and MySQL--and I'm trying to find the best way to
update multiple records, and I've not found any information on how to do
this--can anyone help me find a way to do this for multiples instead of
having to modify records one at a time?

Thanks,

Russ


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to