title: PHP - Get total of values displayed in table
body: <p>I am using a pre defined php inventory manager.
  So in sales my data is getting stored this way:</p>
  
  <pre><code>[{"product_id":"8","total_number":"70","selling_price":"110"}]
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/VCrJp.jpg" alt="enter image description here"></p>
  
  <p>To display these values in table I use the following code</p>
  
  <pre><code>$sub_total          =   0;
  $invoice_entries    =   json_decode($row['invoice_entries']);
  foreach ($invoice_entries as $row2):
      $sub_total  +=  ($row2-&gt;total_number * $row2-&gt;selling_price);                                       
  endforeach;
  
  $sub_total      =   $sub_total - ( $sub_total * ($row['discount_percentage'] / 100) );
  $grand_total    =   $sub_total + ( $sub_total * ($row['vat_percentage'] / 100) );
  echo $grand_total;
  </code></pre>
  
  <p>I get the desired output here which is the total value of the sale.</p>
  
  <p><img src="https://i.stack.imgur.com/xzHCT.jpg" alt="enter image description here"></p>
  
  <p>Now, I am trying to give a report feature which will show all the invoices with the client name, sale value.
  I want to calculate the total of all the invoices and show in a table row i.e. Total of <code>$grand_total</code>. </p>
  
  <p>I am unable to understand how do I get that. Any java script could do it? I don't understand js well. So I have no clue if its possible with it or not. </p>
  
  <p>Thanks in advance </p>