Possible Duplicate:
How do I format numbers to have only two decimal places?
I have looked all over for a solution. Say i have a variable with a number like this:
$price1 = 1597;
$price2 = 1497.85;
Is there a function that displays 2 decimal places without rounding off when there is a even number:
$price1 = 1597.00;
$price2 = 1497.85;
UPDATE:
I have found the problem, the SUM(total) MySQL function rounds off the value:
$result = mysql_query("SELECT SUM(total), SUM(subtotal) FROM jos_vm_order_list WHERE user_id = '$user_id'");
while($totalrow = mysql_fetch_array($result))
{
$total = $row['SUM(total)'];
$total = number_format($total, 2, '.', '');
$subtotal = $row['SUM(subtotal)'];
$subtotal = number_format($subtotal, 2, '.', '');
}
Is there anyway it can not round off while using the MySQL SUM() function?
Thank you for the help in advance.