Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
problem with math and adding numbers to database
Old 07-17-2010, 05:14 PM problem with math and adding numbers to database
Novice Talker

Posts: 12
Trades: 0
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);
//-----------------------------------------
 
$attdamagemysql_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;
 
 
 
 
  
$newhpmysql_query('UPDATE users SET hp= "\''.$user2suphp.'\'" WHERE username=\''.$row3['username'].'\'');
 
 }
 
 
 
//text-----------------------
if($user2suphp==|| $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/>';
 
 
 } 
xwhitchx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to problem with math and adding numbers to database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.54041 seconds with 12 queries