Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

currency formating

Status
Not open for further replies.

blanius

Programmer
Mar 3, 2002
30
US
Hi I'm trying to figure out what field type to store money and how to display it formated with commas etc.

I know there is a format function in MySQL but how do I use it in my PHP?

Bret
 
You don't store currency data formatted with commas. You simply store it as FLOAT(11,2), or whatever number of leading digits you want plus two decimals.

You format currency only upon output. This is because you want to be able to perform calculations on it while in the database. Fortunately, the wise PHP devs have foreseen this need and given us a nice little function called number_format() ( If you need even more control over your output formatting, you can use the standard sprintf() command ( -------------------------------------------

"Calculus is just the meaningless manipulation of higher symbols"
                          -unknown F student
 
Thanks, Knew there would be a simple answer, Hope that php book I ordered gets here soon.....:)

Again thanks
Bret
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top