title: How to get shopping cart quantity count to not require page reload or different page to count
body: <p>I have the following code that gives me a live count of how many items are in the shopping cart. The issue is, it is not so live. I have to either reload the page or go to another page for it to show.</p>
  
  <p>The way I have this is the following code is in a page called loadProducts.php. On every page I use the required function to load it.</p>
  
  <pre><code>//Shopping Cart Quantity Count
  
      if(isset($_SESSION['shopping_cart']) &amp;&amp; is_array($_SESSION['shopping_cart'])) {
      $totalquantity = 0;
      foreach($_SESSION['shopping_cart'] AS $product) {
          $totalquantity = $totalquantity + $product['quantity'];
      }
     }
  
  
   else {
         $totalquantity = 0;
    }
  </code></pre>
  
  <p>I do not know much about Ajax at all, but I'm thinking this may be the only option. </p>
  
  <p>Does it matter that this is ran with a session? How could I get a live element of this to show up on every page so when I click add to cart, it happens right then?</p>