Page 1 of 1
Poll...
Posted: Fri Aug 23, 2002 12:24 am
by Zoram
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...
Posted: Fri Aug 23, 2002 12:30 am
by hob_goblin
MySQL or Flat(text) Files?
Posted: Fri Aug 23, 2002 12:39 am
by Zoram
I'll be using MySQL
Posted: Fri Aug 23, 2002 12:48 am
by hob_goblin
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.
Posted: Fri Aug 23, 2002 1:44 pm
by JPlush76
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