Welcome Guest, Not a member yet? Register   Sign In
CountVotes where ansid
#1

[eluser]benfike[/eluser]
How can I count the votes number for a ansid?

Code:
votes_answer
*voteid
*ansid
*answer
votes_votes
*id
*ansid
*voteid
*userid

Thats my tables!

Code:
function countVotesByAnsId($id){
        $this->db->where('ansid', $id);
        $data = 0;
        $Q = $this->db->get('votes_votes');
        if($Q->num_rows() > 0){
            $data = $Q->num_rows();
        }
        $Q->free_result();
        return $data;
    }
But this dont work. :S I think this look the the VoteID because on the url-string 3 is the voteid.
http://www.arsenalfan.hu/szavazas/eredmeny/1 here you view the problem.

The total votes: 12

Something has 9 votes this true. But the "Valami" only has 3 votes and this write 9 again.

I hope you know what I speakBig Grin
#2

[eluser]jedd[/eluser]
I think your schema is .. sub-optimal. Can you describe it a bit better?

Also $this->db->count_all_results() is your friend.




Theme © iAndrew 2016 - Forum software by © MyBB