flashguy82 Posted September 21, 2006 Share Posted September 21, 2006 Hi, i'm having some trouble getting my price field right. I have set it as a "DOUBLE" field but it's very stupid ill give u an example this is ok "49.99" that will show up but say if i do this "49.00" the ".00" won't show up, it's only with 0's i have the problem also say i add this "49.50" it will show up as "49.5" does anyone know where i'm coming from? can anyone help me out with this? Thanks - Erik Quote Link to comment Share on other sites More sharing options...
hostfreak Posted September 21, 2006 Share Posted September 21, 2006 So when you try to update/insert it, it does that (takes all 0's off)? Give this a read: http://dev.mysql.com/doc/refman/5.0/en/data-types.html Quote Link to comment Share on other sites More sharing options...
warewolfe Posted September 21, 2006 Share Posted September 21, 2006 Hi, use the c style string commands to get a formatted answer. check out sprintf in the php manual for more information$price = 49.50;$formattedPrice = sprintf("%01.2f", $price);echo"$formattedPrice"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.