javascript - PHP - Get total of values displayed in table -
i using pre defined php inventory manager. in sales data getting stored way:
[{"product_id":"8","total_number":"70","selling_price":"110"}]
to display these values in table use following code
$sub_total = 0; $invoice_entries = json_decode($row['invoice_entries']); foreach ($invoice_entries $row2): $sub_total += ($row2->total_number * $row2->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;
i desired output here total value of sale.
now, trying give report feature show invoices client name, sale value. want calculate total of invoices , show in table row i.e. total of $grand_total
.
i unable understand how that. java script it? don't understand js well. have no clue if possible or not.
thanks in advance
since storing data in database, can use query sum grand_total record want retrieve.
select sum(grand_total) yourtable yourfilter
if grand_total
sum query, can use nested select statement it.
http://www.mysqltutorial.org/mysql-subquery/
this link have example on nested select.
Comments
Post a Comment