Question
How to insert a value into a table
I have an ordering system. It displays all the orders by
customer ID. If an order is complete, a check number is entered for
the corresponding line item, otherwise it is left blank.
My code uses the following code to display the form. All are display fields only, except for the last one, where the check number can be entered.
<cfoutput query="qryDetail" group="partNumber">
<tr>
<td valign="top" class="TitleText" align="center">#lineItem#</td>
<td valign="top" class="TitleText" align="center">#OrderNumber#</td>
<td valign="top" class="TitleText" align="center">#partNumber#</td>
<td valign="top" class="TitleText" align="center">#dollarformat(qryDetail.unitValue)#</td>
<td valign="top" class="TitleText" align="center">
<cfinput type="text" name="checkNumber#keyID#">
<input type="hidden" name="keyID" value="#qryDetail.keyID#">
</td>
I use something like the following to update the table with the check numbers entered.
<cfloop index="KeyID" list="#form.KeyID#" delimiters=",">
<cfquery name="qryUpdate" datasource="dbName">
update tblChecks
set checkNumber = '#Evaluate("form.checkNumber#KeyID#")#'
where custID = '#form.custID#'
and KeyID = '#KeyID#'
</cfquery>
</cfloop>
Now we have another table that will contain the customer order history. If the check number was entered for a particular line item, I need to insert that line item nubmer into this table, along with some other columns. I tried to use the same loop, then other loops, but cannot seem to get this to work. Seems simple enough, but I obvisouly am missing something.
How would I insert the line item number (only if a check number was entered for that line item) into the table ?
My code uses the following code to display the form. All are display fields only, except for the last one, where the check number can be entered.
<cfoutput query="qryDetail" group="partNumber">
<tr>
<td valign="top" class="TitleText" align="center">#lineItem#</td>
<td valign="top" class="TitleText" align="center">#OrderNumber#</td>
<td valign="top" class="TitleText" align="center">#partNumber#</td>
<td valign="top" class="TitleText" align="center">#dollarformat(qryDetail.unitValue)#</td>
<td valign="top" class="TitleText" align="center">
<cfinput type="text" name="checkNumber#keyID#">
<input type="hidden" name="keyID" value="#qryDetail.keyID#">
</td>
I use something like the following to update the table with the check numbers entered.
<cfloop index="KeyID" list="#form.KeyID#" delimiters=",">
<cfquery name="qryUpdate" datasource="dbName">
update tblChecks
set checkNumber = '#Evaluate("form.checkNumber#KeyID#")#'
where custID = '#form.custID#'
and KeyID = '#KeyID#'
</cfquery>
</cfloop>
Now we have another table that will contain the customer order history. If the check number was entered for a particular line item, I need to insert that line item nubmer into this table, along with some other columns. I tried to use the same loop, then other loops, but cannot seem to get this to work. Seems simple enough, but I obvisouly am missing something.
How would I insert the line item number (only if a check number was entered for that line item) into the table ?
