function addHealth($id, $health) { $user = getUser($id); $amount = Clamp($user['health'] + $health, 0, getUsersMaxHealth($id)); $lSql = "UPDATE ip_users SET health=:hp WHERE id=:id"; $lStmt = $db->prepare($lSql); $res = $lStmt->execute(array(":hp" => $amount, ":id" => $id)); return $res; }
$('document').ready(function(){ updateEnergyTime();//manually do it once }); </script> </head> <div id="headerDiv"> Simple Game </div> <div id="statusDiv"> <table id='statusTable'> <?php echo "<input type='hidden' id='lastGivenTime' value='" . $loginRes['lastEnergyGiven'] . "' />"; echo "<tr>"; echo "<td id='nameAndExp'>" . $loginRes['username'] . " (" . $loginRes['level'] . ") [" . $loginRes['exp'] . "/" . nextLevelExpNeeded($loginRes['level']) . "]</td>"; echo "<td id='HP'>Health:" . $loginRes['health'] . "/" . getUsersMaxHealth($_SESSION['login']) . " </td>"; echo "<td id='Gold'><span style='vertical-align:middle'>" . $loginRes['gold'] . "</span><img src='images/goldCoin1.png' alt='gold' style='vertical-align:middle'/></td>"; echo "<td id='Energy'>Energy:" . $loginRes['energy'] . "/" . getUsersMaxEnergy($_SESSION['login']) . " [<span id='energyTime'></span>]</td>"; echo "</tr>"; ?> </table> <div id="logoutDiv"> <a href="index.php?logout=1"><input type="button" id="logoutButton" name="logoutButton" value="Logout" /></a> </div> <div class="clearDiv"> </div> </div> <table id="navBar"> <tr> <td id="navBar_Home" href='index.php'><a href='index.php' class='unstyledLink'>Home</a></td>