illegalife Posted December 6, 2008 Share Posted December 6, 2008 I want the query to give exactly 10% of energy but this is not right $db->query("UPDATE users SET energy=energy+10 WHERE userid=$userid"); $db->query("UPDATE users SET energy=maxenergy WHERE energy > maxenergy"); What do i do so it is the percent not the value? Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted December 6, 2008 Share Posted December 6, 2008 Re: [v2] Adding exact % energy $db->query("UPDATE users SET energy=maxenergy/10 WHERE userid=$userid"); $db->query("UPDATE users SET energy=maxenergy WHERE energy > maxenergy"); Maybe? Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy One also has to question the point of using two queries... Ever heard of LEAST() Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy Very informative Nyna + 1 Quote Link to comment Share on other sites More sharing options...
POG1 Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy $energy = floor($ir[energy] * 10%); maybe something like that? Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy im sure that would not work $energy = floor($ir[energy] * $ir[maxenergy]/10); now that's 10 % let me make it clear what im saying is 10% in-case someone misunderstands me lol $ir[maxenergy]/10 ^^ Quote Link to comment Share on other sites More sharing options...
POG1 Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy $energy = floor($ir[energy] * 10%); That would work; 10% is a tenth of a whole so to times it by any number would give a tenth of the number. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy but i always thought % wouldn't work since you not specifying what your wanting a percentage of, i maybe wrong Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy lol @ Zero.. I said the same thing early in post.. They will not always be exact 10% though...Like Luke said. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted December 7, 2008 Share Posted December 7, 2008 Re: [v2] Adding exact % energy lmao ok use floor($ir[maxenergy]/10) i mean obviously there will be a little left over but close enough... 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.