문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top