Poll with PHP [closed]

-1

10 users will respond to a poll with 19 equal options for everyone, each response is saved in the database in a table called 'votes' with the following structure: id: 1 - user_id: 1 - response: {user response}

I want to count all 10 responses and show the highest voted, for example. 3 people have voted for 'CASA'. 5 people voted on 'JOB' and 2 people voted on 'LEISURE' option.

How can I show that the most voted was WORK and that 5 people voted for it?

    
asked by anonymous 16.06.2018 / 22:42

1 answer

1

If I understood your question correctly ...

and if the table is so .....

thenselectthis

Selectresposta,count(resposta)fromvotosgroupbyrespostahavingcount(resposta)=(Selectmax(A.CNT)from(Selectcount(resposta)asCNTfromvotosgroupby(resposta))asA)

andtheresultisthat

    
17.06.2018 / 02:50