-2

I have value which stored in database like price. 123.00

When i tried to see the subtotal which is quantity * price. So 123.00*1 = 123.00 But in view it shows 123 instead of 123.00 where price showing like 123.00 in same table. How can i show decimal value after multiplication?

User57
  • 2,453
  • 14
  • 36
  • 72

1 Answers1

0

You need to format the number using number format PHP function. Consider

$price = 125;
$quantity = 1;   
echo number_format($quantity*$price,2);

You can also have extra comma separated values that set the decimal separator, i.e. "." and the thousands separator also i.e. ",". See http://php.net/manual/en/function.number-format.php

Keith Ivison
  • 387
  • 4
  • 11