update multiple fields with same/diffrent name
I have the form is displayed order no, message and sent_date. Mesage and Date sent are editable. I can change value from both colums in diffrent values then hit submit for update. My code below is loop thur message and date sent field then update them based on the pk ID. Unfortunately, it didn't work as the expected. Can you please help?
| Oder NO | Message | Date Sent |
|---|---|---|
| 5463 | first message | 12-10-12 |
| 5463 | second message | 10-13-12 |
<cfset myIds = ArrayNew(1)>
<cfform name="update" method="post">
<cfloop query="qMesg">
<cfscript>
ArrayAppend(myIds, "#id#");
</cfscript>
<cfinput type="text" value="#mesg#" name="mesg">
<cfinput type="text" value="#dateformat(sent_date, 'mm-dd-yy')#" name="sent_date" validate="date" />
<cfinput type="submit" name="submit" value="Update">
</cfloop>
<cfset myIdsList = #ArrayToList(myIds, ",")#>
<cfinput type="hidden" name="ids" value="#myIdsList#">
</cfform>
<!---update--->
<cfif isDefined("form.submit")>
<cfloop index="idIdx" list="#newsids#" delimiters=",">
<cfloop list="#form.mesg#" index="x">
<cfloop list="#form.sent_date#" index="y">
update [tblMessg]
set mesg = <cfqueryparam value="#x#" cfsqltype="cf_sql_varchar">,
sent_date = <cfqueryparam value="#y#" cfsqltype="cf_sql_date">
where id = <cfqueryparam value="#idIdx#" cfsqltype="cf_sql_integer">
</cfloop>
</cfloop>
</cfloop>
</cfif>
