troubleshooting Question

inserting multiple items using cfform and cfloop

Avatar of slackie
slackie asked on
Web Servers
5 Comments1 Solution321 ViewsLast Modified:
Hi. I have a catalog list of items on a single page, that are outputed by a simple query. It is a shopping cart, so I am trying to get the user to input the quantity they want to purchase of each item into an input box, and then submit the order with one order button at the bottom of the page. That then posts to an additems page that inserts the item number, quantity, and a few pre-set variables. Below is my code, and I am lost.

Order Page
----------
<form action="addtest.cfm" method="post" name="addtest">
<cfoutput query="getproducts">

<tr>
     <td align="center"><cfif #getproducts.image# neq ""><td class="content">#getproducts.id#</td>
     <td class="content">#getproducts.item#</td>
     <td class="content">#getproducts.size#</td>
     <td class="content">US#LSCurrencyFormat(getproducts.price, "local")#</td>
     <td class="content"><input type="text" class="quantity" name="quantity" size="2"></td>
</tr>

<input type="hidden" name="storeid" value="#storeid#">
<input type="hidden" name="ID" value="#getproducts.id#">
<input type="hidden" name="customernumber" value="#sessionid#">
<tr>
     <td colspan="6"><input type="submit" name="order" class="order" value="ORDER">
</td>
</tr>
</cfoutput>
</form>


So from this I want to update a table named cart with only the fields below. I know I should probably be using cfloop as there are multiple item id's and multiple quantities. Below is the update query I would use if it was a single entry I was trying to make. How do I insert the multiple items and the quantities entered into the cart table?

Update Page (addtest.cfm)
-----------


<CFQUERY NAME="UpdateOrder" connectstring="#application.connectString#" dbtype="DYNAMIC">
     INSERT INTO cart (storeid, customer_id, itemnumber, itemquantity, dateentered)

     VALUES (#storeid#, '#customernumber#', '#id#', #quantity#, #now()#)
 </CFQUERY>
ASKER CERTIFIED SOLUTION
modulo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros