seany123 Posted November 26, 2008 Share Posted November 26, 2008 okay so i made this query.... $query = $db->execute("update `players` set `points`=?, `nerve`=? where `id`=?", array($player->points - 10, $player->nerve + 100, $player->id )); but i want it so $player->nerve + 100 CANT go higher than $player->maxnerve. im a bit of a noob and i tried: $query = $db->execute("update `players` set `points`=?, `nerve`=? where `id`=?", array($player->points - 10, $player->nerve + 100 <= $player->maxnerve, $player->id )) but when running it, it took awaye the "points" but made $player->nerve = 0. Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 26, 2008 Author Share Posted November 26, 2008 anyone know how to do this?? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 If you wrote that line of code then you would be able to fix this and wouldn't call your self a noob. So i think we can assume you didn't write it, you most likely copied it or followed a tut and didn't understand. What you need to do is make an if statement outside of this line (before) and make sure the value is under 100 or make one in the class (i don't know much OOP) Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 27, 2008 Author Share Posted November 27, 2008 yes i did write the code myself thankyou very much! and i am a noob, for still having to ask questions like this. and <= 100 is easy... but i need it to be "<= maxnerve" because "maxnerve"s value doesnt stay the same. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 Well one line of code is not enough to get detailed help from. And tbh i still doubt you wrote it or , or you know what it does/how it does it. Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 27, 2008 Author Share Posted November 27, 2008 well i dont really care what you doubt... im still learning php so atleast give me some credit for what ive achieved so far. the best i can come up with is what i posted... Details?? what more details are needed... Both "nerve" and "maxnerve" are rows in a table called "players". i just want it so when "nerve" cant go any higher than the value of "maxnerve" Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 I didn't ask for details i asked for code. Show us the variables and the execute function. Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 27, 2008 Author Share Posted November 27, 2008 i cant see why any other code is needed... im asking a fairly simple question, which im sure most good developers could answer in seconds. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 Dude if you want help don't try personal insults, people on this forum are not paid and we give our time to help. If you want to be arrogant and not cooperate when i am trying to help you suit your self, but seeing as i am the only one trying to help maybe you should just do what is asked. i cant see why any other code is needed... im asking a fairly simple question, which im sure most good developers could answer in seconds. You can't see why any other code is needed, yet you can't fix it , see a reason yet? And if you are going to be immature and throw personal insults then don't expect anyone here to even try and help. Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 27, 2008 Author Share Posted November 27, 2008 im not throwing any personal insults... im clearly stateing a fact that all i want is for someone to show me the way i would set the query up, and i would expect it to be a fairly simple job for most skilled developers. thats all. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 Ok, i will take that as you saying you don't want help from people. 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.