title: How to create a simple shopping cart using PHP sessions?
body: <p>I am creating a cart for my page and this is my first time that I am creating a shopping cart. I have an understanding in PHP sessions and how to use them but I am having a difficulty in creating my cart.</p>
  
  <p>So far here's what I have.</p>
  
  <pre><code>$category   =   $_GET['cat'];
  $product_id =   $_GET['product'];
  
  $product_detail = get_allproduct_detail($product_id); //query to get product info
  
  $prod_price = $product_detail['prod_price'];
  $sale_price = $product_detail['sale_price'];
  $prod_type  = $product_detail['prod_type'];
  </code></pre>
  
  <p>Here's the product part</p>
  
  <pre><code>&lt;div id="main_item_img"&gt;
      &lt;img src="/ahm/images/aroma/large/&lt;?php echo $category; ?&gt;/&lt;?php echo get_product_img($_GET['product']); ?&gt;.jpg" /&gt;
      &lt;div id="magnify"&gt;
          &lt;div class="zoom fitInBox"&gt;Fit in the Box&lt;/div&gt;
          &lt;div class="zoom originalSize"&gt;Original Size&lt;/div&gt;
          &lt;div class="zoom zoomin"&gt;zoom +&lt;/div&gt;
          &lt;div class="zoom zoomout"&gt;zoom -&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;form method="POST" action=""&gt;
  
      &lt;div id="item_detail_right"&gt;
          &lt;label&gt;Qty:&lt;input type="text" name="qty" value="1" size="5" style="text-align: center" /&gt;
          &lt;input type="button" value="+Cart" /&gt;
          &lt;input type="button" value="+Wishlist" id="mywishlist" data-wishlist-id="&lt;?php echo $_GET['product']; ?&gt;" /&gt;
          &lt;input type="hidden" name="product_price" value="&lt;?php echo $prod_price; ?&gt;" /&gt;
          &lt;input type="hidden" name="sale_price" value="&lt;?php echo $sale_price; ?&gt;" /&gt;
          &lt;input type="hidden" name="product_id" value="&lt;?php echo $_GET['product']; ?&gt;" /&gt;
          &lt;input type="hidden" name="product_name" value="&lt;?php echo strtoupper(get_product_name($_GET['product'])); ?&gt;" /&gt;
  
      &lt;/div&gt;
  
  &lt;/form&gt;
  
  &lt;div id="cart_list"&gt;
      &lt;!-- This should be display the cart list --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How can I create a function for adding/updating prices and removing cart item? What I want is after the user click the add to cart. It will simple display a section or div in the same page displaying the product cart and the total. Do i need to setup an AJAX for this or simple pure PHP code? I am also a beginner in AJAX process.</p>
  
  <p>How can I do this? Can you give me an example of this?</p>