tbl_Polls
PollID autonumber PK
PollQuestion text
DateAdded date/time
PollStatus number
tbl_PollAnswers
AnswerID autonumber PK
PolID number
SortID number
Tbl_PollResults
ResultID autonumber PK
PollID number
AnswerID number
DateAdded date/time
IPAddress text
I can grab a poll who’s status is NOT 0 from tbl_Polls, then grab all
Answers from PollAnswers where PollID = PollID from my first query ordered
by SortID… and that’s all to display the poll and build the form.
The form fields were radio buttons named something like PollOption
value=”#AnswerID#”
1 1 1 9/10/2004 192.168.1.101
2 1 3 9/11/2004 192.168.1.102
3 1 2 9/12/2004 192.168.1.103
4 1 3 9/13/2004 192.168.1.104
ResultsID is of course the ID of the record in the result table
PollID is what poll the result belongs to
AnswerID is the answer they chose
DateAdded is the date/time they took the poll
IPAddress is #cgi.remote_addr# just so they don’t submit over and over
I’d have to check but I’m pretty sure I got result count before displaying
the polls. If they were less than 100, I allowed it to be taken again; else
I set the status to 0, closing the poll for good.
The percentage results I had worked no matter the number of results, but I
liked it ending up a nice round number.
Now I can grab the number of results for any poll
I can get the date last used from the latest date in tbl_Answers
If the field existed, add its value to the database it’s value is the
answered, a hidden field for the pollID and your in business
_____
From: Daniel Kessler [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 09, 2004 7:39 AM
To: CF-Talk
Subject: poll DB
I'm doing a poll and determined this morning that I should use a
relational DB. It's pretty basic, but it is my first one so I'd
appreciate it if y'all could check out the code before I go down this
path.
<!-- a list of polls. Write to db once for each answer and then
group on display ** is this right? **. Hopefully there's a way to get
the first GROUP of an output, just in case there're multiple -->
create table fsnep_polls (
p_id NUMBER Primary Key,
p_date_added date,
p_date_last_used date,
p_question VARCHAR2(400),
p_answer NUMBER Foreign Key REFERENCES fsnep_pollAnswers(pA_id),
p_status INT
)
CREATE SEQUENCE unique_poll_Num_s START WITH 1
<!-- all possible answers for any poll available -->
create table fsnep_pollAnswers (
pA_id NUMBER Primary Key,
pA_answer INT
)
CREATE SEQUENCE unique_pollAnswers_Num_s START WITH 1
<!-- all votes with their poll and answer ID -->
create table fsnep_pollVotes (
pV_id NUMBER Primary Key,
pV_date_added date,
pV_poll_id NUMBER Foreign Key REFERENCES fsnep_polls(p_id),
pV_poll_Answer INT Foreign Key REFERENCES fsnep_pollAnswers(pA_id)
)
CREATE SEQUENCE unique_pollVotes_Num_s START WITH 1
Thanks and good morning!
--
Daniel Kessler
Department of Public and Community Health
University of Maryland
Suite 2387 Valley Drive
College Park, MD 20742-2611
301-405-2545 Phone
www.phi.umd.edu
_____
[HYPERLINK "http://www.houseoffusion.com/lists.cfm/link=t:4"Todays Threads]
[HYPERLINK "http://www.houseoffusion.com/lists.cfm/link=i:4:177656"This
Message] [HYPERLINK
"http://www.houseoffusion.com/lists.cfm/link=s:4"Subscription] [HYPERLINK
"http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=678.598.4"Fast
Unsubscribe] [HYPERLINK "http://www.houseoffusion.com/signin/"User Settings]
[HYPERLINK
"https://www.paypal.com/cgi-bin/webscr?amount=&item_name=House+of+Fusion&bus
iness=donations%40houseoffusion.com&undefined_quantity=&cmd=_xclick"Donation
s and Support]
_____
HYPERLINK "http://www.houseoffusion.com/banners/view.cfm?bannerid=36" \n
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.754 / Virus Database: 504 - Release Date: 9/6/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.759 / Virus Database: 508 - Release Date: 9/9/2004
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]