title: Values in session array are being cleared when I update them
body: <p>I'm building a shopping cart and have come up against a problem that I can't figure out.</p>
  
  <p>When I save the updated quantities in the shopping cart, it clears the values stored in the <code>$_SESSION['cart']</code> except the value that I updated.</p>
  
  <pre><code>&lt;?php
  session_start();
  
  $new = $_GET['new']; //new product entry into cart
  
  if($new){
      if(!isset($_SESSION['cart'])){
          $_SESSION['cart'] = array();
          $_SESSION['items'] = 0;
          $_SESSION['total_price'] = '0.00';
      }
      if(isset($_SESSION['cart'][$new])){
          $_SESSION['cart'][$new]++;
      }else{
          $_SESSION['cart'][$new] = 1;
      }
      //$_SESSION['total_price'] = calculate_price($_SESSION['cart']);
      //$_SESSION['items'] = calculate_items($_SESSION['cart']);
  };
  
  if(isset($_POST['save'])){                                -----
      foreach($_SESSION['cart'] as $newId=&gt;$qty){                |
          if($_POST[$newId] == '0'){                             | I think the
              unset($_SESSION['cart'][$newId]);                  | problem is
          } else {                                               | here?
              $_SESSION['cart'][$newId] = $_POST[$newId];        | 
          }                                                 -----
      }
      //run price and item functions
  };
  
  if(($_SESSION['cart']) &amp;&amp; (array_count_values($_SESSION['cart']))){
      $cart = $_SESSION['cart'];
      foreach($cart as $newProd=&gt;$qty) {
          require 'connect.inc.php';
          $query = "SELECT `product_id`, `new_id`, `name`, `price`, `image` FROM `products` WHERE `new_id` = '$newProd'";
          if ($query_run = mysql_query($query)) {
              while ($query_row = mysql_fetch_assoc($query_run)) {
                  $product = $query_row['name'];
                  $price = $query_row['price'];
                  $image = $query_row['image'];
                  $productId = $query_row['product_id'];
                  $newId = $query_row['new_id'];
  $tile = &lt;&lt;&lt;TILE
      &lt;article class="itemCart"&gt;
          &lt;h1&gt;$product&lt;/h1&gt;
          &lt;img src="$image"&gt;    
          &lt;p&gt;$price GBP&lt;/p&gt;
          &lt;form action="shopping-cart.php" method="post"&gt;&lt;label for="$newId"&gt;Quantity &lt;/label&gt;
          &lt;input id="cartQty" type="number" value="$qty" max="30" min="0" name="$newId"&gt;&lt;/br&gt;
          &lt;input type="submit" name="save" value="Update"&gt;&lt;/form&gt;
      &lt;/article&gt;
  TILE;
      echo $tile;
              }
          } else {
              echo mysql_error();
          }
      }
  }else{
      echo '&lt;h2&gt;No items in your shopping cart&lt;/h2&gt;';
  };
  </code></pre>