Forum Moderators: coopster

Message Too Old, No Replies

zero is getting dropped off in my vaiables

         

will1480

2:09 pm on Jun 19, 2004 (gmt 0)

10+ Year Member



lets say I query a table and get back 1.1 . I would like it to display 1.10 (like $1.10). In the database I believe it is 1.10 . Is round the only good work around for this, or is there something that I need to insure is correct in the table definitions?

I will try round($value,2) in the mean time.

ergophobe

4:01 pm on Jun 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It depends on what you want to do.

Mysql returns all values as strings, so if you want them treated as something else, you must cast them.

If you were doing math, though, there is no difference between 1.1 and 1.10, so I assume that this is a problem for output. In that case, you could use

sprintf()

Tom

coopster

3:08 pm on Jun 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Also see
number_format [php.net]
money_format [php.net]