PHP‎ > ‎

How to fix rounding problems with PHP variable

If you are populating a PHP variable from an ADO recordset field that has decimal places, you must use special code to have the variable display the decimals and properly calculate:

To calculate:

$total=floatval($total)+number_format(floatval($rs->Fields['total']->value),2);

To display:

echo number_format(floatval($total),2);
Comments