mysql comma issue

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

mysql comma issue

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post 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
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Post by arjan.top »

if you want to store number in db as int you will have to do it unformatted
Post Reply