lional Posted September 2, 2008 Share Posted September 2, 2008 Hi all I am trying to write a shopping cart that allows for the customer to purchase more than one product in one transaction and then press the buy button. The code on the products list page is: <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; print <<<PRICES <td valign="top"> <select name="$prod_id_out"> <option value="0"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> <td> $size_inch_out</td> <td>$size_mm_out</td> <td>$price_out</td> </tr> PRICES; } ?> and my view cart is: <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; $final_var = '$' . $prod_id_out . '_out'; $post_line = $final_var . ' = $_POST["' . $prod_id_out . '"]'; eval("\$post_line = \"$post_line\";"); } ?> I am having problems with the view cart. I need to find a way to dynamically assing the variables and then I want to check if the value is greater than 0, to add the product to the cart Any help will be appreciated 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.