The quantity of the commodity is x, and then the total is added.

clipboard.png

$dishPrice = 0;
$dishAmount = 0;
$dishPriceV = 0;
          
$dishPrice = $dish->{"price"}; //  
$dishAmount = $dish->{"amount"}; // 
$dishPriceV += $dishPrice * $dishAmount;

print out each box

$dishPriceV

he will add the above
, for example, the first one is 14 is right
, but the second should be 5.6
he adds the above 14 to 19.6
the third should be 719.98 instead of 739.58

.
Mar.11,2021

your + = symbol must be wrong.


do you use loops to calculate the total price? You need to set total to 0 for each loop, and that's fine.


put $dishPriceV = 0; in the loop

can ps: put the code a little bit, just a few lines?


it seems that you are calculating directly with floating-point numbers. It is recommended to change floating-point numbers into integers and try again.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b386ed-2c108.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b386ed-2c108.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?