robbins Posted March 4, 2007 Share Posted March 4, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41177-solved-help-comparing-two-thingys-just-read-it/ Share on other sites More sharing options...
coldkill Posted March 5, 2007 Share Posted March 5, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41177-solved-help-comparing-two-thingys-just-read-it/#findComment-199509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.