PHP - get the total number of values ​​displayed in the table.

I am using a predefined php inventory manager. Therefore, in sales, my data is stored in this way:

[{"product_id":"8","total_number":"70","selling_price":"110"}]

enter image description here

To display these values ​​in a table, I use the following code

$sub_total          =   0;
$invoice_entries    =   json_decode($row['invoice_entries']);
foreach ($invoice_entries as $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 get the desired result here, which is the overall value of the sale.

enter image description here

Now I am trying to provide a report function that will show all invoices with the customer name, sales value. I want to calculate the total amount of all invoices and show in the row of the table, i.e. In total $grand_total.

I can’t figure out how to get this. Any java script could do this? I do not understand very well. Therefore, I do not know if this is possible with this or not.

Thanks in advance

+4
source share
1

, , grand_total , .

select sum(grand_total) from yourTable where yourFilter

if grand_total , select .

http://www.mysqltutorial.org/mysql-subquery/

.

+3

All Articles