Im having a problem that my while loop is not finishing even when the conditions have been meet.
$turn = "0";
while ($player['health_n'] > "0" OR $opponent['health_n'] > "0" AND $turn < "25"){
$turn = $turn+1;
$hitfor = $youatk / $oppdef;
if ($hitfor <= "0"){
echo "$turn. $opponent[name] blocked.<br />";
}else{
echo "$turn. You hit $opponent[name] for $hitfor damage.<br />";
mysql_query("UPDATE members SET health_n=health_n-$hitfor WHERE id='$opponent[id]' ")or die(mysql_error());
}
$turn = $turn+1;
$atkfor = $oppatk / $youdef;
if ($atkfor <= "0"){
echo "$turn. You blocked.<br />";
}else{
echo "$turn. $opponent[name] hit you for $atkfor damage.<br />";
mysql_query("UPDATE members SET health_n=health_n-$atkfor WHERE id='$player[id]' ")or die(mysql_error());
}
}
I am getting the data from the database outside of the while loop; if this is any help.