Forums
This topic is locked
Update Multiple Recsords
Posted 17 Sep 2004 20:23:17
1
has voted
17 Sep 2004 20:23:17 Ammar Jamal posted:
Hi all I need help with this since I am not expert at all , I have a recordset which will retrieve one or more than one record at a time, then I have Update record which will use this records to update another table .
When there is only one record every thing is great BUT if more than one record , only the first record is updated , I think I need to use cfloop but I don’t know were and how to use it (as I mentioned before I am not expert and I cannot write code) Thank you all .
AJ
This is the code :
<cfparam name="SESSION.MM_Username" default="" type="Any">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord"

<cfquery datasource="MPData">
UPDATE PRODUCTS SET Stock=
<cfif IsDefined("FORM.stock"

'#FORM.stock#'
<cfelse>
NULL
</cfif>
WHERE CodeNo=#FORM.Code#
</cfquery>
<cflocation url="OrderSubmited.cfm">
</cfif>
<cfquery name="StockUpdate" datasource="MPData">
SELECT PRODUCTS.Stock, PRODUCTS.CodeNo, QueryStock.TBLCart.CodeNo, QueryStock.PRODUCTS.CodeNo,
QueryStock.Expr1, QueryStock.OrderNo, QueryStock.UserName FROM PRODUCTS, QueryStock
WHERE QueryStock.UserName = '#SESSION.MM_UserName#' and QueryStock.TBLCart.CodeNo
= PRODUCTS.CodeNo and QueryStock.Expr1 < PRODUCTS.Stock
</cfquery>