I'm making a PHP/mySQL poll for a site, and I was just wondering if anyone had any suggestions/help/ideas. Here's what I have so far:
In the mySQL database, I have three tables: poll, poll_options, and poll_votes.
Poll
This table has three columns: poll_id (an autoincrementing number), poll_ques (varchar, the actual question), and poll_ans (a number that tells us how many possible answers we have for that poll).
Poll_options
This table also has three columns: poll_associd (an autoincrementing number that corresponds to poll_id in the poll table), poll_ansnum (the number of that particular answer), and poll_choice (varchar, the actual text of the answer)
Poll_votes
This table once again has three columns: poll_ip (I want to record the IP addresses of those who vote in this table to prevent them from voting again), poll_voted (the id number of which poll they voted on), and poll_select (the number of the answer they chose).
So, this is how it would work:
If I had the following poll:
Who is coolest?
Option 1: Me
Option 2: You
Option 3: Tyler Durden
This is what it would look like in the database:
Table poll
poll_id---------poll_ques----------------poll_ans
1---------------Who is coolest?----------3
Table poll_options
poll_associd--------poll_ansnum--------poll_choice
1---------------------1---------------------Me
1---------------------2---------------------You
1---------------------3---------------------Tyler Durden
Table poll_votes
poll_ip----------------poll_voted------------poll_select
000.000.000.004-----1-----------------------3
000.000.000.003-----1-----------------------2
000.000.000.001-----1-----------------------3
000.000.000.002-----1-----------------------1
(sorry about the dashes - it wouldn't let me put spaces)
Now I understand the concepts of everything, but I'm kind of new with PHP, so any suggestions on coding would be greatly appreciated.
Thanks