title: vending machine program php
body: <p>so I'm doing this program on php. It's a simple vending machine program, with 3 images.</p>
  
  <p>The logic: Accumulate their prices each click of the image in $total variable. Then, on clicking display total price, it should display the total price.</p>
  
  <p>Mine however displays only the price of one pop. When i click each images twice, it displays only the price of one pop, the first one.?</p>
  
  <p>Here's what i have so far:
      
  
  <pre><code>        $total = 0;
  
          display_form();
  
          if(!isset($_POST['submit']))
          {
              display_form();
  
              if(isset($_POST['coke'])) //test for when coke-image is clicked
              {
                  $total += 2.00;
              }
              else if(isset($_POST['rootbeer'])) //test for when rootbeer-image is clicked
              {
                  $total += 2.00;
              }
              else if(isset($_POST['lemonlime'])) //test for when lemon lime-image is clicked
              {
                  $total += 1.00;
              }
              else if(isset($_POST['submit']))
              {
                  trackPrice($total);
              }
          }
          else
          {
              display_form(); 
          }
  
                      function trackPrice($total)
          {
              echo "Your price is $total.";
          }
  
  
          function display_form()  //displays actual form
          {
  </code></pre>
  
  <p>Any thoughts? I was planning on putting static on $total? 
  Thanks so much.</p>