How do I allow a user to change the quantity of a product in a shopping cart?

Discussion in 'PHP' started by callisto11, Jul 23, 2008.

  1. #1
    Hi everyone :confused:,

    Im very new to php and mysql and this is my first ever demo website that Im building. To keep the long story short, what I really need help with is that below is a copy of my shopping cart script, I want my user to able to change the quantity of the product that they have added to the shopping cart once they look into their shopping cart. I dont mind if a example can be shown, so that I can understand how Im surpose to create or add the code to my shopping cart code.

    Thank you
    Callisto11


    My shopping cart code:


    <?php
    session_start(); //at the top of all pages. sessions it stores the data about the user in the web server.
    //the session stores session variables for each user,when a session is started the client
    //is given a session identifier

    if (isset($_SESSION['cart'])) {
    ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <style type="text/css">
    <!--
    .style1 {color: #000000}
    .style7 {
    font-size: 12px;
    color: #000000;
    }
    .style8 {
    font-size: 12px;
    font-weight: bold;
    color: #000000;
    }
    .style12 {
    font-size: 14px;
    color: #000000;
    }
    .style19 {font-size: 14px; color: #000000; font-weight: bold; }
    -->
    </style>
    </head>
    <body>
    <div id="top_menu"></div>
    <div id="main_content">
    <div id="top_banner">
    <a href="index.html"><img src="images/roar.jpg" width="391" height="130" alt="home" title="logo" border="0" class="logo" />[/url] </div>




    <div >
    <div class="title style1">
    <p><strong>Shopping Cart</strong></p>
    </div>
    <div class="content_text">
    <table width="40%" border="1" bordercolor="black" bgcolor="">
    <tr>
    <th width="5%"> <span class="style7">STYLE NUMBER</span></th>
    <th width="6%"> <span class="style7">DETAILS</span></th>
    <th width="6%"> <span class="style8">QUANTITY</span></th>
    <th width="7%"> <span class="style8">SIZE </span></th>
    <th width="7%"> <span class="style8">PRICE (per cartoon) </span></th>
    <th width="8%"> -</th>
    <?php
    foreach ($_SESSION['cart'] as $key => $general_cartoon) {
    ?>
    </tr>
    <tr>
    <td><span class="style19"><?php echo $_SESSION['cart'][$key] ['cartoon_id']; ?></span></td>
    <td><span class="style19"><?php echo $_SESSION['cart'][$key] ['title']; ?></span></td>
    <td><span class="style19"><?php echo $_SESSION['cart'][$key] ['quantity'];?></span></td>
    <td><span class="style19"><?php echo $_SESSION['cart'][$key] ['size'];?></span></td>
    <td><span class="style19"><?php echo $_SESSION['cart'][$key] ['fee'];?></span></td>
    <?php $quantity =$_SESSION['cart'][$key]['quantity'];?>
    <td><a href="removefromcart.php?cartoon_id=<?php echo $_SESSION['cart'][$key]['cartoon_id'];?>&location=<?php echo $_SERVER['PHP_SELF'];?>">[REMOVE][/url]</td>
    </tr>

    <?php }?>
    </table>
    <p>
    <?php }
    else { ?>
    No cartoon chosen yet
    <?php }
    ?>
    </p>
    <p>&nbsp;</p>
    <form action="rmgallery.php" method="get">
    <input name="back" type="submit" value="BACK TO GALLERY" title=" Takes you back to the gallery page."/>
    </form>
    <form action= "checkoutlogin.php" method="get">
    <input nane= "get" type="submit" value="GENERAL ORDER" title="A general order will allow you to purchase the cartoons in your shopping cart." />
    </form>
    <form action="questionform.php" method="get">
    <input name="get" type="submit" value="PERSONAL ORDER" title="A personal order will allow you to give a description of details you would like in your cartoon." />
    </form>

    <p>&nbsp; </p>
    <p>&nbsp;</p>
    </div>
    <div class="content_text"></div>

    <div class="title"></div>
    <div class="content_text">



    </div>
     
    callisto11, Jul 23, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Why not using a select field or input field to let users change there quantity?
     
    EricBruggema, Jul 25, 2008 IP