On Tue, Jun 15, 2004 at 03:15:08PM +1000, [EMAIL PROTECTED] wrote: > Hi > > i thought i would try and outline the action i am trying to create, > > i am passing 2 "variables.lists" to an "query update" and would like to loop over > the values. > The variable lists are: > > productid=1,2,3,4,5,6,7 > > price=22,44,55,33,55,33 >
<cfset ProductArray = ListToArray(productid)> <cfset PriceArray = ListToArray(price)> <!--- convert the lists to arrays ---> <cfloop from="1" to="#arrayLen(ProductArray)#" index="LoopCount"> <CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#"> UPDATE products SET unitprice= #val(PriceArray[LoopCount])# <!--- get the VALue of the item in the array PriceArray ---> WHERE productid = '#ProductArray[LoopCount]#' <!--- get the item in the array ProductArray ---> <!--- NOTE: this should be replaced with cfqueryparam ---> <!--- eg: unitprice = <cfqueryparam value = '#ProductArray[LoopCount]#' CFSQLType = "CF_SQL_LONGVARCHAR"> ---> <!--- you'll have to make sure the CFSQLType is correct for the table field type, btw ---> </CFQUERY> </cfloop> Caveat: the number of items in the product list must match the number of items in the price list or this will screw up badly.. Cheers Paul Haddon Technical Services Manager Formstar Print Technologies --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
