title: Calculate (SUM) price given from database
body: <p>I would like to calculate the price every choices the user made.
  In my database all of these products already have different amount on it.</p>
  
  <p>my Pricelist table looks like this: <a href="https://i.stack.imgur.com/hlsZ1.jpg" rel="nofollow noreferrer">Pricelist table</a>
  <em>(is this table advisable?)</em></p>
  
  <p>I did this because I've wanted to display the amount.
  Like this:  <a href="https://i.stack.imgur.com/u3bPP.jpg" rel="nofollow noreferrer">radio button choices</a></p>
  
  <p>At the same time, my admin can update the price.</p>
  
  <p>I have a bunch of choices need to be calculated and I wanted it to be <strong>Calculated Automatically on the interface</strong></p>
  
  <p>What I've got so far and working fine.</p>
  
  <p>Above my price I have php like this, <strong>works well</strong></p>
  
  <pre><code>&lt;?php
    $link = mysql_connect('localhost', 'root', '');
      mysql_select_db("myrnas", $link);
      $query="SELECT * FROM pricelist";
       $myData = @mysql_query($query, $link); ?&gt;
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function updateTotal() { 
  
        var optionprice = 0; //base price to start is 0
      
    function cakeThemePrice() { 
          if (document.getElementById('theme1').checked) {       
              optionprice += 500; }
      
          if (document.getElementById('theme2').checked) {
               optionprice += 200;}
      
          if (document.getElementById('theme3').checked) {
               optionprice += 200; } 
          }
  }
  
    cakeThemePrice();  //function to add them up
    
   var totalPrice = optionprice;
   document.getElementById('totalPrice').innerHTML = "Amount : ₱ " + totalPrice;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    
      &lt;input type="radio" id="theme1" name="cake_theme"  value="wedding" onchange="updateTotal()" /&gt;  Wedding 
        &lt;?php
          while($record=mysql_fetch_array($myData)){
          echo "₱".$record['wedding_price'].""; ?&gt; 
      
       &lt;br&gt; &lt;input type="radio" id="theme2" name="cake_theme"  value="birthday" onchange="updateTotal()" /&gt; Birthday &lt;?php echo "₱".$record['birthday_price'].""; ?&gt; 
      
      &lt;br&gt; &lt;input type="radio" id="theme3" name="cake_theme" value="dedication" onchange="updateTotal()" /&gt;Dedication &lt;?php echo "₱".$record['dedi_price'].""; ?&gt;
      &lt;? php } ?&gt;
      
      &lt;span id="totalPrice"&gt; Amount: &lt;/span&gt; </code></pre>
  </div>
  </div>
  </p>
  
  <p>Well you can see, the price to be displayed is still <strong>hardcoded</strong> , which is I don't want it.
  I've seen codes like SUM and putting <strong>data-price</strong> to get the price in my table but I'm not sure how to use it.
  Thanks in advance!</p>