简体   繁体   中英

minus one total from another PHP

I am trying to work out a members balance, this is the total amount for products minus the total number for payments.

Below is my code;

$prod_total = $qry->fetchColumn();
$payments_total = $row['sum'];
$balance = floatval($prod_total) - floatval($payments_total);
echo" $balance;"

Example, products total is 100.00 - payments are 50.00 and 20.00 and the $balance is showing as -70.00

However this just shows the total for payments as a minus?!? Thanks

try doing the math with floatval() http://www.php.net/manual/en/function.floatval.php

$prod_total = $qry->fetchColumn();
$payments_total = $row['sum'];
$balance = floatval($prod_total) - floatval($payments_total);
echo $balance;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM