Search code examples
phpmysqlvote

Voting eachtime sets to 1 How to solve this?


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?


Solution

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