View Full Version : mysql datatype displaying?
i use int to display 5000
what data type do i use so it will display 5,000
and same with, i use double to display 5000.00
is there a way to display $5,000.00
please keep in mind it cannot be char
because i use it for calculation and etc...
thanks
You should store the number in an unformatted fashion in the database. When you display it on the page, use number_format() or money_format() to display it with formatting.
number_format() or money_format() are those some sort of built in functions?
and where do i add in my .pl scrit ?
is there any examples..
HalfaBee
1-21-04, 09:00 PM
Pig's functions are PHP.
You can do it in SQL as well.
FORMAT(X,D)
Formats the number X to a format like '#,###,###.##', rounded to D decimals. If D is 0, the result will have no decimal point or fractional part:
mysql> SELECT FORMAT(12332.123456, 4);
-> '12,332.1235'
mysql> SELECT FORMAT(12332.1,4);
-> '12,332.1000'
mysql> SELECT FORMAT(12332.2,0);
-> '12,332'
MySQL Reference Manual (C) 2002 MySQL AB
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.