PHP Calculation

I have a form based program featured a Total Deductions value that is calculating fine and looks like this:

echo $str.='<tr class="style14" height=30 style4><td colspan=2>Total Deductions:</td><td colspan=2>$'.number_format($Section179Amount+$BonusDepAmount+$fyearvalue, 2, '.', ',').'</td></tr>';

I want to also provide this value in a % of total cost and changed the echo statement to look like this to incorporate a percent value:

$percent = (number_format($Section179Amount+$BonusDepAmount+$fyearvalue, 2, '.', ',')/number_format($AircraftCost, 2, '.', ','))*100;
 echo $str.='<tr class="style14" height=30 style4><td colspan=2>Total Deductions</td><td colspan=2>$'.number_format($Section179Amount+$BonusDepAmount+$fyearvalue, 2, '.', ',').' - '.number_format($percent, 0, '.', ',').'% (of cost)</td></tr>';

I am using the *100 to take the decimal value and convert to %
Example:  400000/500000 = .8
.8 *100 = 80%

This works fine for this calculation but when I change the values to 620000/1000000 the % calculates to 62,000 % ???

What am I doing wrong?
pda4meAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Must be the commas you are adding to the formatting. Calculate the $percent without the commas.
0
pda4meAuthor Commented:
hello, thanks for the reply.  can you give me an example based on what I provided?
0
hieloCommented:
$n = $Section179Amount+$BonusDepAmount+$fyearvalue;
$d = $AircraftCost;
$percent = (($n/$d)*100);
echo $str.='<tr class="style14" height=30 style4><td colspan=2>Total Deductions</td><td colspan=2>$'.number_format($Section179Amount+$BonusDepAmount+$fyearvalue, 2, '.', ',').' - '.number_format($percent, 0, '.', ',').'% (of cost)</td></tr>';
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pda4meAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.