HI just found a solution about add and sustract two columns here but I need to make the php code to format the numbers.
Here is the solution I got here:
<?php while ($row= mysqli_fetch_assoc($result)) { echo $row['money'] - $row['cost']; } ?>
Its working fine for what I need but here is the thing. I use to run the follow php code to all money and numbers
<?php echo number_format($product['cost'],0, ",", "."); ?>
That way the numbers will display without decimals and like this 100.000
How can I make the code I found here to work with number format?
Something like this I tried but does not work
<?php while ($row= mysqli_fetch_assoc($result)) { echo number_format$row['money'] - number_format$row['cost']; } ?>
It must substract and then show the result with formated numbers
Advertisement
Answer
you need to put it in ()
echo number_format($row['money'] - $row['cost'],0,',','.');
More than 2 :
echo number_format($row['money'] - $row['cost'] + $row['whatever'] * $row['whatever'],0,',','.');