flemingmike Posted December 9, 2010 Share Posted December 9, 2010 hello all, i have a small problem. i have a bunch of prices in a database like 243.49 and 1,256.22 etc. the problem is that when i try to add multiple prices that one of the fields is over 1000, it is treating it as 1 (i believe because of the comma.) is there a way to remove the comma, but not the decimal if it exists and then add it back to the $total if it is over 1000? $pamount=$row2['amount']; $total += $pamount; Quote Link to comment https://forums.phpfreaks.com/topic/221131-remove-comma-before-adding/ Share on other sites More sharing options...
litebearer Posted December 9, 2010 Share Posted December 9, 2010 what is the field TYPE you are using in the table for prices? Quote Link to comment https://forums.phpfreaks.com/topic/221131-remove-comma-before-adding/#findComment-1144967 Share on other sites More sharing options...
PFMaBiSmAd Posted December 9, 2010 Share Posted December 9, 2010 Remove - http://us3.php.net/manual/en/function.str-replace.php Put back - http://us2.php.net/manual/en/function.number-format.php All the basic things that php (or mysql) can do, can be found by looking in the php/mysql documentation. Quote Link to comment https://forums.phpfreaks.com/topic/221131-remove-comma-before-adding/#findComment-1144969 Share on other sites More sharing options...
flemingmike Posted December 9, 2010 Author Share Posted December 9, 2010 thanks Quote Link to comment https://forums.phpfreaks.com/topic/221131-remove-comma-before-adding/#findComment-1144981 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.