rxbanditboy1112 Posted April 12, 2007 Share Posted April 12, 2007 I am trying to bring a value out of mysql which is a decimal value (10,2) so it will have 2 decimal places. When an item is added to the cart it's price is in a decimal value also. Its qty is an integer. When i try to output the item's price x the qty, and the number has no significant digits to the right of the decimal point it wont give me the decimal point with 2 0s (.00). Basically if the number is 280.00 in the database i want it to look like that. I think the problem comes from multiplying an integer and a decimal value. I am doing this: $row[item_price]*$row[item_qty] I tried: (float)$row[item_price]*$row[item_qty] but it does the same thing. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/46748-decimal-point-in-php/ Share on other sites More sharing options...
per1os Posted April 12, 2007 Share Posted April 12, 2007 www.php.net/number_format $price = number_format(($row[item_price]*$row[item_qty]), 2, '.', ''); Should work. Link to comment https://forums.phpfreaks.com/topic/46748-decimal-point-in-php/#findComment-227801 Share on other sites More sharing options...
rxbanditboy1112 Posted April 12, 2007 Author Share Posted April 12, 2007 It worked!!! Thanks Link to comment https://forums.phpfreaks.com/topic/46748-decimal-point-in-php/#findComment-227815 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.