Page 1 of 1

mysql comma issue

Posted: Wed Dec 26, 2007 6:47 am
by itsmani1
Hello,

I want to show show float and int values with comma in mysql database.

Like if i enter 1000 or 1000.00 it should take it as 1,000 or 1,000.00

is there any way to do this?


thank you

Posted: Wed Dec 26, 2007 7:08 am
by VladSun
http://bg.php.net/function.number_format

Code: Select all

echo number_format(12345678.12345, 2, '.', ',');
echo number_format(12345678, 2, '.', ',');
output:
12,345,678.12
12,345,678.00
PS: Also, you can do this at DB layer:
http://dev.mysql.com/doc/refman/5.0/en/ ... ion_format

Posted: Wed Dec 26, 2007 7:39 am
by arjan.top
if you want to store number in db as int you will have to do it unformatted