Sorry guy's the last gym didn't show the guard rank... Here Is an updated and fixed version,
<?php
$macropage="gym.php";
require "globals.php";
if($ir['hospital']) { die("<prb>This page cannot be accessed while in hospital.</prb>"); }
$statnames=array(
'Strength' => 'strength',
'Agility' => 'agility',
'Guard' => 'guard',
'Labour' => 'labour');
$_POST['amnt']=abs((int) $_POST['amnt']);
if(!$ir['jail'])
{
print "<h1>Gym</h1><hr width='70%' align='left' />";
}
else
{
print "<h1>Jail Gym</h1><hr width='70%' align='left' />";
}
if($_POST['stat'] && $_POST['amnt'])
{
$stat=$statnames[$_POST['stat']];
if(!$stat)
{
die("<prb>This stat cannot be trained.</prb>");
}
if($_POST['amnt'] > $ir['energy'])
{
print("<prb>You do not have enough energy to train that much.</prb><hr width='70%' align='left' />");
}
else
{
$gain=0;
for($i=0; $i<$_POST['amnt']; $i++)
{
$gain+=rand(1,3)/rand(800,1000)*rand(800,1000)*(($ir['will']+20)/150);
$ir['will']-=rand(1,3);
if($ir['will'] < 0) { $ir['will']=0; }
}
if($ir['jail']) { $gain/=2; }
$db->query("UPDATE `userstats` SET `{$stat}` = `{$stat}` + $gain WHERE `userid` = $userid");
$db->query("UPDATE `users` SET `will` = {$ir['will']}, energy = energy - {$_POST['amnt']} WHERE `userid` = $userid");
$inc=$ir[$stat]+$gain;
$inc2=$ir['energy']-$_POST['amnt'];
if($stat=="strength")
{
print "You start to lift some weights, You go heavier and heavier until You are out of energy.<br />
You have gained {$gain} strength by doing {$_POST['amnt']} sets of weights.<br />
You now have {$inc} strength and {$inc2} energy left.";
}
elseif($stat=="agility")
{
print "You Begin to run on the treadmill, You keep tapping the faster button till you fly off the damn thing!.<br />
You have gained {$gain} agility by doing {$_POST['amnt']} minutes of running.<br />
You now have {$inc} agility and {$inc2} energy left.";
}
elseif($stat=="guard")
{
print "You jump into the pool and begin swimming, you keep flapping your arms in the water like Michael Felps, you get a cramp and almost drown.<br />
You have gained {$gain} guard by doing {$_POST['amnt']} minutes of swimming.<br />
You now have {$inc} guard and {$inc2} energy left.";
}
elseif($stat=="labour")
{
print "You walk over to the front desk, and ask the manager If you can volunteer to help the gym out, He says unload the boxes In the back, You unload boxes until the gym closes<br />
You have gained {$gain} labour by unloading {$_POST['amnt']} boxes.<br />
You now have {$inc} labour and {$inc2} energy left.";
}
print "<hr />";
$ir['energy']-=$_POST['amnt'];
$ir[$stat]+=$gain;
}
}
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
print "<table width='70%'><tr><td><p>GYM
<br />You can train up to <prb>{$ir['energy']}</prb> times with your
current energy.</p></td></tr></table>
<hr width='70%' align='left' /><br />
<table width='70%' class='table'>
<tr>
<form action='gym.php' method='post'>
<input type='hidden' name='stat' value='Strength'></input>
<th width='15%'><ph2>Strength:</ph2></th>
<td width='15%'>{$ir['strength']}</td>
<td width='10%'>(Rank {$ir['strank']})</td>
<td width='40%'>Times to train: <input type='text' name='amnt' value='{$ir['energy']}' length='5'></input></td>
<td width='20%'><input type='submit' value='Go!'></input></td>
</form>
</tr>
<tr>
<form action='gym.php' method='post'>
<input type='hidden' name='stat' value='Agility'></input>
<th width='15%'><ph2>Agility:</ph2></th>
<td width='15%'>{$ir['agility']}</td>
<td width='10%'>(Rank {$ir['agirank']})</td>
<td width='40%'>Times to train: <input type='text' name='amnt' value='{$ir['energy']}'></input></td>
<td width='20%'><input type='submit' value='Go!'></input></td>
</form>
</tr>
<tr>
<form action='gym.php' method='post'>
<input type='hidden' name='stat' value='Guard'></input>
<th width='15%'><ph2>Guard:</ph2></th>
<td width='15%'>{$ir['guard']}</td>
<td width='10%'>(Rank {$ir['guarank']})</td>
<td width='40%'>Times to train: <input type='text' name='amnt' value='{$ir['energy']}'></input></td>
<td width='20%'><input type='submit' value='Go!'></input></td>
</form>
</tr>
<tr>
<form action='gym.php' method='post'>
<input type='hidden' name='stat' value='Labour'></input>
<th width='15%'><ph2>Labour:</ph2></th>
<td width='15%'>{$ir['labour']}</td>
<td width='10%'>(Rank {$ir['labrank']})</td>
<td width='40%'>Times to train: <input type='text' name='amnt' value='{$ir['energy']}'></input></td>
<td width='20%'><input type='submit' value='Go!'></input></td>
</form>
</tr>
</table><br /><hr width='90%' align='left' /><br /><br />";
$h->endpage();
?>