PDA

View Full Version : SQL updates another field.


Mhtml
04-14-2003, 02:22 PM
This is so weird, I'm writing a little poll thing for my website and I've run into a problem..

$update = 'UPDATE mith_poll SET ans7N = 3 WHERE id = 1';
mysql_query($update);

When I vote on an answer it will go up +1 but when I pick a different answer after the last field has been updated the same field gets updated again, I then have to vote again to make the second choice go up + 1..

Am I making sense?
I'll try a bit harder for those who don't understand..


I select answer A
Answer A gets updated
I select answer B
Answer A gets updated
I select answer B,C,D,E and which ever I picked gets updated
I select answer F and the last answer gets updated

raf
04-14-2003, 02:46 PM
Not making sense to me, since i only see that litte statement and don't know anything about your tabledesign or how you update the values.

i typically would make a table like
[id][alternative][countalt]
1 a 10
2 c 9
3 b 200

and update it like

$update = ("UPDATE mith_poll SET countalt = countalt+1 WHERE alternative ='" . $_POST["alt"] . "'");

Mhtml
04-14-2003, 03:14 PM
I'm saying that I have to submit the form twice to increment the count on an option the first time.

Then if I try another option it increments the last option...

ASAAKI
04-14-2003, 05:00 PM
such problems love to creep up.
i had a forum where when a user posted for the first one or two times, his post count went up properly, after that it updated his post count two a time, like from 3 to 5 to 7...:rolleyes:
why not just post all ur relevant code