greetings to everyone.
does anyone know how to format INT variables from MySQL and display it in a page as the following format.
Example.
in my database:
field name: balance
data type: int
value: 1000
how can i format it so that i can display it in the page as P 1,000.00 ?
note: P stands for philippines peso.
How to display INT from MySQL to 1,000.00 format?
Moderator: General Moderators
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: How to display INT from MySQL to 1,000.00 format?
Have a look at either:
http://us3.php.net/number_format
http://us3.php.net/money_format (If you aren't on Windows)
There's also stuff like FORMAT if you prefer to do it on the DB side:
http://dev.mysql.com/doc/refman/5.0/en/ ... ion_format
http://us3.php.net/number_format
http://us3.php.net/money_format (If you aren't on Windows)
There's also stuff like FORMAT if you prefer to do it on the DB side:
http://dev.mysql.com/doc/refman/5.0/en/ ... ion_format
Re: How to display INT from MySQL to 1,000.00 format?
Thanks for the response. If i use the MySql side. Can i get it and display it as 1,000.00 in my page?
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: How to display INT from MySQL to 1,000.00 format?
Yes, if you do it on the DB side, the raw result you get back from your query will be the formatted version (1,000.00).
Re: How to display INT from MySQL to 1,000.00 format?
ok then, What data type should i use? INT?double? or decimal?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How to display INT from MySQL to 1,000.00 format?
I just looked in the MySQL manual and found these pages:
http://dev.mysql.com/doc/refman/4.1/en/ ... n_truncate
http://dev.mysql.com/doc/refman/4.1/en/ ... types.html
http://dev.mysql.com/doc/refman/4.1/en/ ... n_truncate
http://dev.mysql.com/doc/refman/4.1/en/ ... types.html
(#10850)
Re: How to display INT from MySQL to 1,000.00 format?
I think it's best to use DECIMAL.