0

i'm doing php project on e-voting and i've a data goes from voters in the databse can u help me to give me the php code that counts the votes in voting seesion and display the result..plzzzzz

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by R0bb0b
0
mysql> select count(vote) as total, vote from votes group by vote;

will show you the total of votes per distinct vote entry.

0

thanx rob...i need to ask u a question. Is it the same that we 're using different table 'vote'. to store votes. did i ve to use this code for this matters?

OK, so here's the query I presented

select count(vote) as total, vote from votes group by vote

the syntaxt would be like this

select count(column) as total, column from table group by column;

what this is doing is for each distinct vote, counting the amount of votes that match that distinct vote, hence group by column. So if I had a table called polvotes and my columns were candidates and voter which stores the name of the voter and the candidate the voter voted for. The only thing that I am really concerned about is the candidate column and the number of votes per distinct candidate so my query would be:

select count(candidates) as total, candidates from polvotes group by candidates

I hope this explains what is going on and I hope that helps. It is a very simple design but ultimately that is what it comes down to. Then your program would then parse the results and do whatever with them.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.