4
中顯示的值總數
我正在使用預先定義的php庫存管理器。 所以在銷售我的數據是越來越這種方式存儲:PHP - 獲取表
[{"product_id":"8","total_number":"70","selling_price":"110"}]
要顯示在表中我用下面的代碼,這些值
$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;
我這裏得到需要的結果是銷售總額。
現在,我想給的報告功能,它會顯示所有與客戶名稱,銷售價值的發票。 我想計算所有發票的總數,並在表格行中顯示,即總計爲$grand_total
。
我無法理解我該如何得到它。任何Java腳本可以做到這一點?我不明白js。所以我不知道它是否可能。
在此先感謝
使用不同的庫存管理器 – Strawberry
@Strawberry:良好的建議,但現在不適用,因爲客戶已經開始使用它:) – user1299086
創建一個變量,簡單地命名爲'$ final_total',當重載頁面時,初始值爲0,'$ final_total + = $ grand_total'在每行獲得$ grand_total值,然後顯示它 –