huntrguy102 Posted April 28, 2010 Share Posted April 28, 2010 I have this code function showCart5() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM books WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $total += $price * $qty; $output[] = '<strong> $'.$total.'</strong>'; } } else { $output[] = ' '; } return join('',$output); } which is basically posting the final price. I am working on a book store and when someone puts in more than 1 different book. it posts the price of the first book and then the total price of both books. I think its a problem with the foreach part of the function. Is there a way I can replace the foreach with something else that will just post the final total? here is the link to the bookstore http://www.chulainnlibros.com/cart/index.php . If you try it your self you may have any idea of what I'm talking about. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 28, 2010 Share Posted April 28, 2010 Huh? Quote Link to comment Share on other sites More sharing options...
huntrguy102 Posted April 30, 2010 Author Share Posted April 30, 2010 never mind..... 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.