tags:

views:

68

answers:

2

Each time i vote up or down it just sets an 1. But i want that votes_up=votes_up+1 inkrements eachtime i vote up.

this is php code

 public function voteUp($id)
  {
    $this->initDB();

    $q="update twitter.tweets set vote_up=vote_up+1 where id=$id";
    $this->db->query($q);
  }

the result is

Down Votes:1

Up Votes:1

Total Votes:18

How can i solve that Down Votes and Up Votes are inkremented?

+2  A: 

You aren't setting $id or something else is going wrong. This SQL looks fine. .

Chuck Vose
id is correct set so with id is everything ok if the id were wrong i couldnt set the vote up to set on for that id
streetparade
Did you try running that SQL in the console? Because I bet it works just fine.
Chuck Vose
sorry that was a template problem so your answer is correct pls edit your answer so that i can vote up and accept your answer
streetparade
editted. Try now. Thanks for the upvote
Chuck Vose
Your are welcome have a nice evening
streetparade
A: 

I assume there is a voteDown() function of basically the same structure. Perhaps that is also being called unnecessarily.

Have you looked at the database structure? Perhaps the data type is wrong for the vote_up column. I would think you would want the type to be int unsigned not null default 0.

amphetamachine