> I've got a cfloop/form structure set up to allow a user to
> update one or two
> specific fields in specific records.
> ID of Record = #MyQuery.Record_ID#
> Data field to update = BOB
> The loop and form sorta like (not real code):
> <cfloop>
> <form>
> <select name="BOB_#MyQuery.Record_ID#">
> <hidden name="RecID" value="#myQuery.Record_ID#
> <submit>
> </form>
> </cfloop>
> Using the following query code
> <cfloop index="UpdateID" list="#Form.RecID#">
> <cfquery datasource="MyData">
> UPDATE dbo.app_Master
> SET BOB = '#evaluate("FORM.BOB_#UpdateID#")#',
> WHERE MSTR_ID= '#UpdateID#'
> </cfquery>
> </cfloop>
> I'm having trouble getting only the specific record to
> update though... it wants to update them all......
You mean only the records that have changed? ...
the update statement looks a little funny -- where mstr_id = '#updateid#'
.. if this is coming from form.recid and form.recid is a comma delimited
list of myquery.record_id, did you use an alias in myquery? Or does
myquery.record_id == dbo.app_Master.mstr_id ? I only ask because the column
names are different, so presumably if you're updating the same table in your
db, you'd have had to either used an alias in the query on the form page,
mis-paraphrased the form page code, or you'd be attempting the update with
probably the wrong unique identifiers.
If you want to update only the records which were changed on the form, then
you need to pass an additional hidden form field with each select box to
indicate the original values for comparison.
Also, I'd change your evaluate -- it's probably better to use this
UPDATE dbo.app_Master
SET BOB = '#form["BOB_#updateid#"]#'
WHERE MSTR_ID = '#UpdateID#'
It won't solve your problem, but it's less code and it's more efficient for
the server.
hth
s. isaac dealey 954-776-0046
new epoch http://www.turnkey.to
lead architect, tapestry cms http://products.turnkey.to
certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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