Jump to content

[SOLVED] Help Comparing Two Thingys... Just Read It!


robbins

Recommended Posts

Ok, I'm making a small fight script.

 

You pick a name from the list, and then it runs the fight script and checks your stats compared to the persons you picked.

 

So basically...

 

how would i get php to pull from a mysql database and compare to see if one is bigger than the other. For example... say I had 50 Strength and user2 had 47 Defense... my strength is higher, so I win...  but how would i get the php code to check my strength against user2's defence and then run code like echo you win....????

 

Please Help... Thx

Use an if statement.

 

Get the data from the database using the mysql_query function then do something like:

 

if( $guy1_defense >= $guy2_strength )
{
      echo 'You win!';
}
elseif( $guy1_defense == $guy2_strength )
{
      echo 'Draw!';
}
else
{
     echo 'You loose!';
}

 

Cold

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.