Page 1 of 1

Currency: php/mysql

Posted: Mon Jun 07, 2004 8:21 pm
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

Posted: Mon Jun 07, 2004 8:35 pm
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