Jump to content

Archived

This topic is now archived and is closed to further replies.

gerkintrigg

Mysql Float variables - 2 decimal places

Recommended Posts

Hi. this is probably a very simple question, with a very simple answer, but it's baffling me...

Does anyone here know how to echo a MySQL float variable as two decimal places? Currently I'm using it to store prices in a database and whenever a cost if like £1.50p it only displays £1.5 which simply looks wrong.

Can anyone help please?

Thanks.

Share this post


Link to post
Share on other sites
I know the round function works

round(5.2545, 2) would be 5.25

round(1.5,2) should in theory be 1.50

Share this post


Link to post
Share on other sites
Also check out the number format and the money format functions

http://es2.php.net/manual/en/function.number-format.php

http://es2.php.net/manual/en/function.money-format.php

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.