I have a form that populates form fields with database
records to edit.
This works fine.
When i attempt to loop through the records to update i get an
error.
Obviously it has to do with my syntax of my variables (
LowerQty='form.LowerQty#count#',
UpperQty='form.UpperQty#count#',
Price=form.Price#count# WHERE id='form.id#count'# )
When i attempt to update the database. It is attempting to
enter the string
value "lowerQty1" rather that it actual intger value=1. What
is the correct
syntax to write these variables in cold fusion? Thanks in
advance.
<!----form------>
<cfset count=0>
<form name="form2"
action="pricecode_adjust.cfm?stage=update"
method="post">
<table width="600" border="1">
<cfoutput query="PriceCodes" startrow="1"
maxrows="#pricecodes.recordcount#">
<cfset count=#count#+1>
<tr>
<td width="100px">Price Code:
#pricecode# <input name="id#count#" type="text"
value="#pricecodes.id[count]#" /></td>
<td width="100px">Lower Qty#count#:
<input type="text" name="LowerQty#count#" size="6"
maxlength="6"
value="#pricecodes.lowerqty[count]#" /> </td>
<td width="100px">Upper Qty#count#:
<input type="text" name="UpperQty#count#" size="6"
maxlength="6"
value="#pricecodes.upperqty[count]#" /></td>
<td width="100px">Price#count#: <input
type="text" name="Price#count#" size="6" maxlength="6"
value="#pricecodes.price[count]#" /></td>
</tr>
</table><input name="Update" type="submit"
id="Update"
value="Update Price Code" />
<!-----store the loop count in hiiden field---->
<input name="recordcount" type="hidden"
value="#pricecodes.recordcount#" />
</cfoutput>
</form>
<!----update------>
<cfif stage eq 'update'>
<!---Loop through pricecodes to be updated--------->
<cfloop index="Count" from="1"
to="#form.recordcount#">
<cfquery name="query" datasource="#client.dsn#"
username="#client.username#" password="#client.password#">
UPDATE cost
SET
LowerQty='form.LowerQty#count#',
UpperQty='form.UpperQty#count#',
Price=form.Price#count#
WHERE
id='form.id#count'#
</cfquery>
</cfloop>
</cfif>