Dethman Posted July 12, 2008 Share Posted July 12, 2008 Hello all, I am trying to figure out how to get the percentage between two numbers such as "2500" and "1250" I am using this code for the SQL query but cant figure out how to get a percentage range between 1% and 100% the percentage is the percent of the damaged weapon. its like this, if weapon is 25% damaged I need to it to say Weapon Status 75% of capable power lol does anyone get this? mysql_query("select `weaponDefaultStrength` AND `strength` from `user_weapons` where `userid`='$userID'") or die(mysql_error()); Please Help ??? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 12, 2008 Share Posted July 12, 2008 Well if 1250 is your weapons current status and 2500 is your weapons max status or health or whatever. Then apply the maths rule: PERCENT = (1250/2500) * 100 So... Put this in your game: $weaponFullStrength = 1800; $weaponStrength = 900; $damangePercent = (ceil($weaponFullStrength / $weaponStrength) * 100); //this gives us the damage percentage $capablePower = 100 - $damagePercent; echo "Weapon Status: {$capablePower}% of capable power."; Hope that cleared a few things up, and I answered your question. (Is it ceil() in PHP, I'm sure it is. Darn javascript!) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.