Jump to content

help with a query.


seany123

Recommended Posts

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.

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.