title: Very simple shopping cart, remove button
body: <p>I'm writing sales software that will be walking through a set of pages and on certain pages there are items listed to sell and when you click buy it basically just passes a hidden variable to the next page to be set as a session variable, and then when you get to the end it call gets reported to a database.</p>
  <p>However my employer wanted me to include a shopping cart, and this shopping cart should display the item name, sku, and price of whatever you're buying, as well as a remove button so the person doing the script doesn't need to go back through the entire thing to remove one item.</p>
  <p>At the moment I have the cart set to display everything, which was fairly simple. But I can't figure out how to get the remove button to work. Here is the code for the shopping cart:</p>
  <pre class="lang-php prettyprint-override"><code>$total = 0;
  //TEST CODE:
  $_SESSION['itemname-addon'] = &quot;Test addon&quot;;
  $_SESSION ['price-addon'] = 10.00;
  $_SESSION ['sku-addon'] = &quot;1234h&quot;;
  
  $_SESSION['itemname-addon1'] = &quot;Test addon1&quot;;
  $_SESSION ['price-addon1'] = 99.90;
  $_SESSION ['sku-addon1'] = &quot;1111&quot;;
  
  $_SESSION['itemname-addon2'] = &quot;Test addon2&quot;;
  $_SESSION ['price-addon2'] = 19.10;
  $_SESSION ['sku-addon2'] = &quot;123&quot;;
  //end test code
      
  $items = Array
  (
      &quot;0&quot;=&gt; Array
      (
        &quot;name&quot; =&gt; $_SESSION['itemname-mo'],
        &quot;price&quot; =&gt; $_SESSION ['price-mo'],
        &quot;sku&quot; =&gt; $_SESSION ['sku-mo']
      ),
      &quot;1&quot; =&gt; Array
      (
        &quot;name&quot; =&gt; $_SESSION['itemname-addon'],
        &quot;price&quot; =&gt; $_SESSION ['price-addon'],
        &quot;sku&quot; =&gt; $_SESSION ['sku-addon']
      ),
      &quot;2&quot; =&gt; Array
      (
        &quot;name&quot; =&gt; $_SESSION['itemname-addon1'],
        &quot;price&quot; =&gt; $_SESSION ['price-addon1'],
        &quot;sku&quot; =&gt; $_SESSION ['sku-addon1']
      ),
      &quot;3&quot; =&gt; Array
      (
        &quot;name&quot; =&gt; $_SESSION['itemname-addon2'],
        &quot;price&quot; =&gt; $_SESSION ['price-addon2'],
        &quot;sku&quot; =&gt; $_SESSION ['sku-addon2']
      )
      
    );
  
  $a_length = count($items);
  
  for($x = 0; $x&lt;$a_length; $x++){
  $total +=$items[$x]['price']; 
  }
  $formattedtotal = number_format($total,2,'.','');
  for($i = 0; $i &lt; $a_length; $i++){
  $name = $items[$i]['name'];
  $price = $items[$i]['price'];
  $sku = $items[$i]['sku'];
  displaycart($name,$price,$sku);
  }
  echo &quot;&lt;br /&gt;
  &lt;b&gt;Sub Total:&lt;/b&gt; 
  $$formattedtotal&quot;;
    
    function displaycart($name,$price,$sku){
      
      if($name != null || $price != null || $sku != null){
      
      if ($name == &quot;no sale&quot; || $price == &quot;no sale&quot; || $sku == &quot;no sale&quot;){
      echo &quot;&quot;; 
      }
      else{
        $formattedprice = number_format($price,2,'.','');
        echo &quot;$name: $$formattedprice ($sku)&quot;;
        echo &quot;&lt;form action=\&quot;\&quot; method=\&quot;post\&quot;&gt;&quot;;
        echo &quot;&lt;button type=\&quot;submit\&quot; /&gt;Remove&lt;/button&gt;&lt;br /&gt;&quot;;
        echo &quot;&lt;/form&gt;&quot;;
      }
      
      }
    }
  </code></pre>
  <p>So at this point I'm not sure where to go from here for the remove button.</p>