<?
$users=$db->fetchAll("SELECT `id`,`hp`,`max_hp`,`vip` FROM `users`",NULL);
foreach ($users as $us){

if($us['vip']=="yes"){
$c=2;
} else {
$c=1;
}

  if($us['hp']<$us['max_hp']){
$proc=floor($us['max_hp']/100*5)*$c;
$set=$db->query("UPDATE `users` SET `hp`=? WHERE `id`=?",array($us['hp']+$proc,$us['id']));

}
}
?>