krdev krdev - 1 year ago 62
MySQL Question

Wy decimal numbers are not stored as expected in mysql

I'm trying to save numbers in decimal data type filed formated (10,4), but it's not stored as expected ie. 13850 changed to 13.0000 any help.
this is my code:

$c_price = $unit_price*$rate;
$expense->c_price = number_format($c_price, 4);
$expense->c_total = number_format($quantity*$c_price, 4);

Here c_price and c_total values are changed.

Answer Source

Increase the length of digits:


it will work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download