0

Hi
I wrote a php program that shows a poll and people have to vote for it
theres a table in my mysql database for polls:
polls columns:
pollquestion
polloptions
pollvotes
pollvoters
voterschoices

pollquestion column will contain the question of the poll
polloptions will contain all the options for the poll (divided by the sign |)
pollvotes will contain the numbers of the votes of each option respectively..
For example, if the polloptions contained: Option 1 | Option 2 | Option 3
and pollvotes contained: 3 | 50 | 6
that means that the Option 1 got 3 votes, and the Option 2 got 50 votes, and the Option 3 got 6 votes and so on...
pollvoters column will contain the names of the voters; each time a user votes his name will be inserted in the column using the concat function..
voterschoices column will contain the choices of the voters.. each choice will be represented by its Order number (Option 1 will have num 1, Option 3 will have num 3...)

Now how can I write a php code to show what each user has voted?
I wrote a code to do it but it was very bad because it shows a list of users and in front of them it shows their choices.. I want the program to show options and the choices of the users for each option.. for example:
Option 1: John, Selim, Khaled, etc.. (Where these are the names of voters).

Thanks in advance.

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by diafol
0

Can't you just select the amount of votes that an option has received from the pollvotes column, and then display the result behind the poll option?

0

I dont mean that
What I mean is this:
Each option should be viewed and in front of it should be the voters who chose that option

0

This depends on how you're storing pollvotes . Regardless, you could store it in a variable as a string or array, then echo it to the results page.

Regards
Arkinder

0

This is awkward

How about:

[B]users[/B]
user_id (PK)...

[B]polls[/B]
poll_id (PK), poll_title, poll_question...

[B]poll_options[/B]
poll_op_id (PK), poll_id (FK), poll_op_text...

[B]poll_results[/B]
user_id (FK), poll_op_id (FK)  AS composite PK

normalized. dealing with serialised lists in single fields is difficult

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.