3 messages in com.mysql.lists.perlINSERT, UPDATE and Groundhogs
FromSent OnAttachments
Andreas Gietl26 Oct 2001 09:14 
Jonathan M. Morgan26 Oct 2001 10:49 
Rajeev Rumale29 Oct 2001 19:08 
Subject:INSERT, UPDATE and Groundhogs
From:Jonathan M. Morgan (jmor@midsouth.rr.com)
Date:10/26/2001 10:49:30 AM
List:com.mysql.lists.perl

I am working my way through Paul DuBois' excellent book "MySQL and Perl for the Web." One of the examples shows how to conduct a poll- vote for your favorite groundhog: http://www.kitebird.com/cgi-perl/groundhog.pl Paul then suggests modifying the poll "...to log EACH vote and when it occurred so that you can perform time-based analysis of poll activity."

How does one tally the vote (UPDATE) and insert a new record for each vote?

The original MySQL table is as follows:

CREATE TABLE ( name CHAR(10) NOT NULL, tally INT UNSIGNED NOT NULL DEFAULT 0 )

The vote tally is updated like this:

$dbh->do ("UPDATE groundhog SET tally = tally + 1 WHERE name = ?", undef, $name);

I updated the table to include an auto incremented vote_id(PRIMARY KEY) as well as a timestamp. But how do you log each vote and tally the vote?

Thanks!

JMM