Poll...
Moderator: General Moderators
Poll...
I am trying to do all the programming for the web site that I am doing and was wondering how the best way to program a poll would be...
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
you'll want to have two tables...
one for the options of the poll, two columns - "option" and "id" - id will be auto_increment
one for the votes, two columns one for "oid" and one for "count"
the script will grab the options out of the options table, and you will vote...the script will do a query like "SELECT * FROM votes WHERE oid = '$vote'" (vote being the id of what they voted for..). it will do a mysql_num_rows, and if it returns zero it will do an INSERT statement inserting something into the table. if it returns otherwise you will do an UPDATE adding one to the "count"... you will then set a cookie so it won't be done over and over (you need to check for the cookie at the begining)... then just a little math to display the pie chart/bar graph or whatever.
one for the options of the poll, two columns - "option" and "id" - id will be auto_increment
one for the votes, two columns one for "oid" and one for "count"
the script will grab the options out of the options table, and you will vote...the script will do a query like "SELECT * FROM votes WHERE oid = '$vote'" (vote being the id of what they voted for..). it will do a mysql_num_rows, and if it returns zero it will do an INSERT statement inserting something into the table. if it returns otherwise you will do an UPDATE adding one to the "count"... you will then set a cookie so it won't be done over and over (you need to check for the cookie at the begining)... then just a little math to display the pie chart/bar graph or whatever.
-
JPlush76
- Forum Regular
- Posts: 819
- Joined: Thu Aug 01, 2002 5:42 pm
- Location: Los Angeles, CA
- Contact:
here is a great poll tutorial I found on devshed, I used it this week and it works 
http://www.devshed.com/Server_Side/PHP/ ... page1.html
http://www.devshed.com/Server_Side/PHP/ ... page1.html