Zephyris Posted February 11, 2008 Share Posted February 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/90423-teach-me-how-to-make-polls-using-phpmysql/ Share on other sites More sharing options...
tibberous Posted February 11, 2008 Share Posted February 11, 2008 You can do it with two tables: Table One: unsigned int primary key id, varchar(255) question, date created, Table Two unsigned int primary key id, unsigned int ownerId, unsigned int votes, varchar(100) text. Quote Link to comment https://forums.phpfreaks.com/topic/90423-teach-me-how-to-make-polls-using-phpmysql/#findComment-463574 Share on other sites More sharing options...
EchoFool Posted February 11, 2008 Share Posted February 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/90423-teach-me-how-to-make-polls-using-phpmysql/#findComment-463576 Share on other sites More sharing options...
Zephyris Posted February 11, 2008 Author Share Posted February 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/90423-teach-me-how-to-make-polls-using-phpmysql/#findComment-463596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.