Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
$maxHP = 100; //генерирай го както щеш...
$currentHP = 35; //същото...
$currentPR = round(($currentHP/$maxHP)*100); //ПР от проценти...
echo '<style type="text/css">
#hp {
margin: 0;
padding: 0;
width: 100px;
height: 12px;
empty-cells: show;
border: 1px solid #000;
}
.full {
background: #00f;
}
.empty {
background: #f00;
}
</style>
<table id="hp" border="0" cellspacing="0" cellpadding="0"><tr>
';
for($slot=1;$slot<101;$slot++){
if($slot<=$currentPR){$class='full';}else{$class='empty';}
if($slot==1 && $currentPR<1 && $currentHP>0){echo '<td class="full"></td>
'; $slot=2;} //тоя иф предотвратява грешки от сорта на - макс е 4000, а потребителя е на 1 и след като го закръгли пхп в скалата ше покаже че е на 0 хп което дразни потребителя...
echo '<td class="'.$class.'"></td>
';
}
echo '</tr></table>';
<?php
if(isset($_POST['submit'])){
$maxhp = (int) $_POST['maxhp'];
$curhp = (int) $_POST['curhp'];
$full = round(($curhp/$maxhp)*100);
if($full<1 && $curhp>0){$full=1;}
$empty = 100-$full;
echo '<style type="text/css">
#hp {
margin: 0;
padding: 0;
width: 100px;
height: 12px;
empty-cells: show;
}
#full {
background: #00f;
width: '.$full.'px;
}
#empty {
background: #f00;
width: '.$empty.'px;
}
</style>
<table id="hp" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="full"></td>
<td id="empty"></td>
</tr>
</table>';
}else{
echo '<form action="hp.php" method="post">
MAX: <input type="text" name="maxhp">
CURRENT: <input type="text" name="curhp">
<input type="submit" name="submit" value="Submit">
</form>';
}
?>