Jump to content

Teach me how to make polls using php/mysql?


Zephyris

Recommended Posts

Well I've been trying to make polls work with php/mysql... however I've got trouble.

 

mysql

weekly_polls ( id(INT(99)), author(INT(99)), question(TEXT), date(DATE), time(TIME)

weekly_polls_votes ????

 

The thing is, I can't figure out, how will the poll know the options to vote for. I need to be able to add as many option to chose in a poll as needed... so unlimited. I don't have a clue how to do this.

 

I saw forums only use 2 tables.. but i have no clue how they do it because I don't see the poll opinions anywhere, I only see polls and votes...?

 

show me how to structure my tables/database.

Link to comment
Share on other sites

Dont even need 2 tables.

 

If this isnt to do with forum polls this is how i do it for a global site vote one vote per user:

 

Voted  | UserID  |

 

 

As a table then just echo a poll like this where ever you want?

 

Are you male or female?

 

Male = Value 1

Female = Value 2

 

Voted  | UserID  |

  1          23

  2          12

  1            5

  2          100

 

 

And if they try to vote again just do a query to check if their UserID is found in the table if it is then you just say "you cannot vote twice."

If its related to forum polls then you need to add a "threadID" to the table.

Link to comment
Share on other sites

Ok, this I already somewhat understand

 

Let's say a poll looks like this:

 

Question (Are you normal?)

Option1 (Yes)

Option2 (No)

Option3 (Maybe)

 

Sometimes answers(options) are sentences..

 

The user chooses an option.. but where do you store those options? and be able to add as many as you want? And be able to modify it if need be. In your example, that is what I can't figure out.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.