Jump to content

Calculating percentages?


Mutley

Recommended Posts

Hey i made this for my game..

Use it :P

$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
$experc=(int) ( $ir['exp']/$ir['exp_needed']*100);
$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
$enopp=100-$enperc;
$wiopp=100-$wiperc;
$exopp=100-$experc;
$bropp=100-$brperc;
$hpopp=100-$hpperc;
print"
<b>Energy:</b> {$enperc}%<br />
<img src=bargreen.gif width=$enperc height=10><img src=barred.gif width=$enopp height=10><br />
<b>Will:</b> {$wiperc}%<br />
<img src=/barblue.gif width=$wiperc height=10><img src=barred.gif width=$wiopp height=10><br />
<b>Nerve:</b> {$ir['brave']}/{$ir['maxbrave']}<br />
<img src=barblack.gif width=$brperc height=10><img src=barred.gif width=$bropp height=10><br />
<b>EXP:</b> {$experc}%<br />
<img src=baryellow.gif width=$experc height=10><img src=barred.gif width=$exopp height=10><br />
<b>Health:</b> {$hpperc}%<br />
<img src=barwhite.gif width=$hpperc height=10><img src=barred.gif width=$hpopp height=10>";

 

Just use it as text ..

 

But if the variables are:

 

$value = '100';

$discount_value = '200'; // Value AFTER discount

 

It does a negative percentage, is it possible to say "200%"? Rather than "-100%".

 

You wanted to show the saving, which is -100%

 

200% is the discount value as percentage of the value - not the same thing.

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.