|
![](/images/resource/spacer.gif) |
|
[รายงานขายสินค้าหากำไรขาดทุน]สอบถามเรื่องการดึงข้อมูล Mysql มาคำนวน แยกส่วน PHP |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (PHP)
//ราคาสินค้ารวม vat
$Total = $result3["item"] * $result3["price1"];
//ราคาสินค้ารวม vat ทั้งหมด
$Sumall = $Sumall + $Total;
แก้เป็น
Code (PHP)
//ราคาสินค้ารวม vat ส่งเข้าตัวแปร $Sumall
$Sumall = ($Total = $result3["item"] * $result3["price1"]);
จากของเดิม $Sumall = $Sumall + $Total; เป็นการเอาค่าเก่ามาบวกซ้ำไปเรื่อย
เคลียร์ให้เป็นค่าใหม่ซะก่อน
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2017-12-02 16:17:53 |
By :
Chaidhanan |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ลองตั้งชื่อตัวแปรให้สื่อความหมายซักหน่อยไหมครับ
Code (PHP)
$Total = $result3["item"] * $result3["price1"];
//ราคาสินค้ารวม vat ทั้งหมด
$Sumall = $Sumall + $Total;
//$_SESSION["sell"][$a]/100; ส่วนลด%
//$_SESSION["sellbath"][$d] ส่วนลดบาท
//$_SESSION["item"][$i] จำนวนสินค้า
//ส่วนลด+ส่วนลดเพิ่มเติม ราคาเต็ม 1750 ผลส่วนลด ตย.175+5 = 180
$discount = $Total*$result["per"]/100+$result["per2"];
//ราคาขายทั้งหมด - ส่วนลด ตย. 1570
$Bal_Vat = $Total-$discount;
//หาราคาทุนบิลนี้
$Balance = $Bal_Vat/1.07;
//หาราคา Vat
$Vat = $Bal_Vat - $Balance;
เพื่อจะได้ไอเดียในการวาง field และ จะรวมอะไรจะได้ บวกได้ง่ายๆ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2017-12-02 18:56:37 |
By :
Chaidhanan |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
กำหนดตัวแปรใน Loop ดูครับ
Code (PHP)
while(xxxxxxx){
$Total=$Sumall=0;
$Total = $result3["item"] * $result3["price1"];
$Sumall = $Sumall + $Total;
}
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2017-12-02 22:18:37 |
By :
somparn |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขอเวลาเอาไปลองหน่อยนะครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2017-12-03 13:34:12 |
By :
Max |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
เอา database มาให้ทดสอบหน่อย
คืออ่านโค๊ดแล้วงง อะครับ คือรูปแบบมันไม่ได้ยากอะไร แต่ดูการคิวรี่ เพื่อนำมาคำนวณแล้วให้รู้สึกงง
ข้อมูลมันไม่ค่อยจะสัมพันธ์กัน (เพราะไม่รู้ database )
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2017-12-04 18:20:40 |
By :
Chaidhanan |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 01
|