padams Posted November 5, 2008 Share Posted November 5, 2008 I am trying to get my shopping cart system working for a website that sells linen. The product pages have two dropdown boxes, - the client can select a product and a style that the product comes in. At the moment, the product page is pointing to an addcart page, which works fine - it is bringing the productID, productname, styleID and the price through from my database. But when you click "checkout" and continue through to 'viewcart.php' the price and product name work fine, but the style is not continued through. Here is one of the product pages: www.humphreyb.stacnz.com/pages/bedlinen.php Here are the queries from the addcart.php page: if (isset ($_GET['productID'])) { // Check for a print ID. $styleID = (int) $_GET['styleID']; $stylequery = "SELECT style FROM styles WHERE styleID=$styleID"; $stylename=mysql_query($stylequery); $style=mysql_fetch_assoc($stylename); $productID = (int) $_GET['productID']; $productquery = "SELECT name FROM products WHERE productID = $productID"; $productname = mysql_query ($productquery); if ($productname) { while ($row = mysql_fetch_array ($productname, MYSQL_ASSOC)) { $name = $row['name']." (".$style['style'].")"; }} And here is the relevant code from the viewcart.php page: //Get info for the contents session variable $_SESSION['names']{$row['productID']} = $row['name']; $_SESSION['styles']{$row['styleID']} = $row['stylename']; // Calculate the total and sub-totals. $subtotal = $_SESSION['cart'][$row['productID']]['quantity'] * $_SESSION['cart'][$row['productID']]['price']; $total += $subtotal; // Print the row. echo "<tr> <td align=\"left\" class=\"text\">{$row['name']} ({$row['stylename']})</td> <td align=\"right\" class=\"text\">\$" . number_format ($_SESSION['cart'][$row['productID']]['price'], 2) . "</td> <td align=\"center\" class=\"text\"><input type=\"text\" size=\"3\" name=\"qty[{$row['productID']}]\" value=\"{$_SESSION['cart'][$row['productID']]['quantity']}\" /></td> <td align=\"right\" class=\"text\">$" . number_format ($subtotal, 2) . "</td> </tr>\n"; } // End of the WHILE loop. The assignment is due tomorrow and everything has to be 100% working! Appreciate all the help. Quote Link to comment Share on other sites More sharing options...
iversonm Posted November 6, 2008 Share Posted November 6, 2008 what errors are you getting? that could make everything alot easier 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.