Jump to content

Decimal Point in PHP


rxbanditboy1112

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.