Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP Rounding Up Issue

Guest
Nov 09, 2009 Nov 09, 2009

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?!

TOPICS
Server side applications
328
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 09, 2009 Nov 09, 2009

I don't know php, but wouldn't you just use the same rounding function (assuming that's what number_format is doing)?

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

Translate
LEGEND ,
Nov 09, 2009 Nov 09, 2009
LATEST

I don't know php, but wouldn't you just use the same rounding function (assuming that's what number_format is doing)?

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines