problem with math and adding numbers to database
so this is my attack code, it looks like it works but no matter how much damage you do it will kill the other player. so if i do 0 dmg to some one with 10 hp it was say i did 0 and i have it echo out how much hp they still has. that all works fine but when i go to the next page all there hp is gone…. i dont understand y it is doing this.
PHP Code:
if ($_GET['att']=='Attack')
{
$att=ceil($user1luk*$user1dex*$user1str/4+$user1int/4+3);
$defend=ceil($user2luk*$user2dex+$user2int/3);
$outcome=ceil($att-$defend);
//-----------------------------------------
$attdamage= mysql_query("SELECT * FROM users WHERE username='$getusername'");
while($row3 = mysql_fetch_array($attdamage))
{
$user2hp= $row3['hp'];
if ($outcome<0)
{
$outcome=0;
}
else{
$outcome=$outcome;
}
$user2suphp= $user2hp - $outcome;
$newhp= mysql_query('UPDATE users SET hp= "\''.$user2suphp.'\'" WHERE username=\''.$row3['username'].'\'');
}
//text-----------------------
if($user2suphp==1 || $user2suphp>0)
{
echo'You did '.$outcome.' Damage to '.$getusername.'<br/>';
echo $outcome.'<br/>';
echo $user2suphp.'<br/>';
echo $newhp.'<br/>';
}
else
{
echo'You did '.$outcome.' Damage to '.$getusername;
echo'you have killed '.$getusername.'<br/>';
}
View full post on Webmaster-Talk.com
ADDING, Database, math, numbers, Problem