|
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
the update query :
<cfloop index='item' list='#form.productid#'
delimiters=','>
<CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#"> UPDATE products SET unitprice= #price# WHERE
(productid = '#item#')
</CFQUERY> </cfloop> the probelm at hand is how to index loop on both
variables and update the table with the correct values.
i am stuck on this one and need some direction if
any one has a snipet or a helpful comment .
it will make my day.
greg
----- Original Message -----
From: [EMAIL PROTECTED]
Sent: Tuesday, June 15, 2004 2:49 PM
Subject: [cfaussie] Re: batch style update Hi i am still stuck on updating a list of prices
does anyone have any pointers for me..
----- Original Message -----
From: [EMAIL PROTECTED]
Sent: Tuesday, June 15, 2004 12:47 PM
Subject: [cfaussie] batch style update I have a batch feature i have developed to update the products table. at this stage i have the check boxes updating and would now like to add a text field for price. the probelm i have is lining up the values so they insert the correct details. with the check boxes i have a simple system re below. <!--- set featured specials and hidprod to no ---> <CFQUERY NAME="resetfeatured" datasource="#prefs.dsn#" > UPDATE products SET featured = 0 <cfif isdefined("form.featured")> where productid NOT IN ('#form.featured#') </cfif> </CFQUERY> <!--- loop over selected fields and update table ---> <cfif isdefined("form.hiddenprod")> <cfloop index='item' list='#form.hiddenprod#' delimiters=','> <CFQUERY NAME="updatehiddenprod" DATASOURCE="#prefs.dsn#"> UPDATE products SET hiddenprod=1 WHERE (productid = '#item#') </CFQUERY> </cfloop> </cfif> this works perfect for the check box enteries but not for products. the problem for the products is lining up the values productid with the values to be updated. hope all this makes sense.... heres the code if anyone can point me in the right direction would be a great help! save the new data <cfif isdefined("form.updateprice")> <cfloop index='price' list='#form.price#' delimiters=','> <cfloop index='item' list='#form.productid#' delimiters=','> <CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#"> UPDATE products SET unitprice='#price#' WHERE (productid = '#item#') </CFQUERY> </cfloop> </cfloop> </cfif> this is the form that submits the data <form action="" method="POST"> <input type="Hidden" name="updateprice" value="updateprice"> <table cellspacing="2" cellpadding="2" border="0"> <tr> <td>Product Part No Name</td><td>Featured</td><td>Special</td><td>Hide</td><td>Price</td> </tr> <cfoutput query="special"> <input type="Hidden" name="productid" value="#productid#"> <tr bgcolor="#IIf(CurrentRow Mod 2, DE('#prefs.rowcolor1#'), DE('#prefs.rowcolor2#'))#"> <td>#productpartno# - #productname#</td> <td><input type="Text" name="price" value="#unitprice#" size="5" maxlength="10"> <cfif "#hiddenprod#" is "yes">checked</cfif></td> </tr> </cfoutput> </table> <input type="Submit" name="save" value="save changes"> </form> regards greg --- 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/ --- 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/ --- 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/ |
