[SOLVED] Curreny Representation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lisamarie_tt
Forum Commoner
Posts: 32
Joined: Fri Jul 15, 2005 8:20 am

[SOLVED] Curreny Representation

Post by lisamarie_tt »

Description of the task:
I would like to insert into a database a currency value from a form or retrive from a data a numeric (float) value and represent it as currency.

Description of the problem:
The insertion is being done, however the values from the from are not being inserted in true float (decimal) form. Example if the from submits:
11.00 dollars --->> 11 is stored
11.50 dollars --->> 11.5 is stored
11.75 dollars --->> 11.75 is stored


When the sorted values are accessed from the database they do not conform to the expected currency format (00.00).

Main Concerns and questions:
1.) Is there a way to store or specifiy to php to take trailing zeros.
2.) Is there a way to format retrived values a curreny.
lisamarie_tt
Forum Commoner
Posts: 32
Joined: Fri Jul 15, 2005 8:20 am

Post by lisamarie_tt »

Got it !!!

I'm using the number_format method to format the number in the form: 0,000.00

Pays to read the PHP Manual.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

lisamarie_tt wrote:Pays to read the PHP Manual.
8)
Post Reply