Jump to content

PHP Rounding Up Issue


kool_samule

Recommended Posts

Hi Chaps,

 

I have an SQL query that calculates a word count multiplied by a fixed figure:

 

...$pricegross = ($row_rsInvPending['projanalysis_total']*$row_rsInvPending['costbase']);...

 

Then use a bit of php code to round up the figure to 2 decimal places....

 

<?php echo number_format($pricegross, 2, '.', ''); ?>

 

I then total up $pricegross for all records:

 

.....SELECT SUM(projanalysis_total) as total_pricegross...

 

If I have two records:

($pricegross) 1. £2.295

($pricegross) 2. £2.295

There are both displayed as £2.30, which is what I want

 

Then the total ($total_pricegross) shows up as £4.59, but what I want is: £4.60

 

Is this possible?....Hope this is clear?!

Link to comment
https://forums.phpfreaks.com/topic/180851-php-rounding-up-issue/
Share on other sites

Clear as mud.  You are saying that you are getting the proper rounding on everything, but one number shows up as 4.59 when it should be 4.60.  How is that number being set? PHP, or MySQL? if it's PHP, have a look at round(), if it's not, we will need more info to help.

 

 

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.