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 Link to comment https://forums.phpfreaks.com/topic/21584-price-field-help/ 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 Link to comment https://forums.phpfreaks.com/topic/21584-price-field-help/#findComment-96349 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"; Link to comment https://forums.phpfreaks.com/topic/21584-price-field-help/#findComment-96383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.