mastersuse
mastersuse

Reputation: 988

PHP how to rounded total

I'm confused to using round function in PHP, I have make some calculation function in my system using PHP, but the answer still not in rounded.

I want all the total will be in percent_complete that have been rounded.

Can someone help me to fixed this code? this is original code..

<?php echo $row_sr1['percent_complete'] = ($row_sr1['partial_complete'] + $row_sr1['full_complete']) / $row_sr1['appt_today'] * 100;?>

and here is code that I've try to rounded but unsuccessful.

<?php echo round($row_sr1['percent_complete']),2 = ($row_sr1['partial_complete'] + $row_sr1['full_complete']) / $row_sr1['appt_today'] * 100;?>

Upvotes: 1

Views: 65

Answers (1)

Amadan
Amadan

Reputation: 198368

Your round function is in the wrong place.

<?php
  echo $row_sr1['percent_complete'] =
         round(
           ($row_sr1['partial_complete'] + $row_sr1['full_complete']) /
             $row_sr1['appt_today'] * 100,
           2);
?>

Upvotes: 3

Related Questions