# 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?
###### Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x

Commented:
\$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

Commented:
Must be the commas you are adding to the formatting. Calculate the \$percent without the commas.
0

Author Commented:
hello, thanks for the reply.  can you give me an example based on what I provided?
0

Author Commented:
Thanks!
0