Schlo_50 Posted February 4, 2008 Share Posted February 4, 2008 Hello, I have an ordering script which i have been working on for a while now. It's in the finishing stages, and lastly i'd like to be able to get the prices of any items selected and total them. What i need help with is associating a selected item with a price. Selected items are put into an array like so: foreach($_POST['orderid'] as $id){ $orderid[] = $id; $orderid = implode(',', $orderid); All information is pulled from my database and is done so using the code below: while($row = odbc_fetch_array($sql2)) { $category = $row["CategoryName"]; $productid = $row["ProductId"]; $productname = $row["ProductName"]; $price = $row["Price"]; $type = $row["Type"]; $habit = $row["Habit"]; $colour = $row["Colour"]; $status = $row["Status"]; // find out if category has changed // if so, print it, and it's contents if ($category != $prevcat) { echo "<p class='title'><u>{$category}</u></p>"; } echo "<p class=main2> <strong>{$productname}</strong> - ({$colour} {$status} Item#{$productid}) <span class=address1>£{$price} <input name=\"orderid[]\" value=\"{$productid}\" type=\"checkbox\"/> <input name=\"quantity[{$productid}]\" type=\"text\" size=\"3\" maxlength=\"3\" /></span></p>"; I don't know how to grab the single price associated with an item when it is selected using a checkbox. Any help/ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted February 4, 2008 Share Posted February 4, 2008 You could add a hidden field with the price for each product <input type='hidden' name='price[$productid]' value='$price'> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.