Currency: php/mysql

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
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Currency: php/mysql

Post by dstefani »

Hello all,

I wasn't sure if I should post this to the DB forum or PHP, so I took a shot...

I need to record the price of an item in a database field.
The value could be anywhere from 10.95 to 120.95.
Then I need to show that value as plain HTML as well as a value in a text field. Do you have any suggestions as to
1/ the best field type in mysql?
2/ and if needed the best way to format the value from php to the browser?

Right now I'm trying DECIMAL(7,2) but if I put a test value of 1,200.00 into the field it comes out 12.00.

Your help is appreciated,

Thanks,

dstefani
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i would suggest a float
something like this

Code: Select all

`price` FLOAT( 11 ) NOT NULL
field name is price(or whatever) and a float with a length of 11(or whatever)
but this will keep whatever decimal you put into it
Post Reply