Re: [PHP] Polls

2001-07-08 Thread Andrew Brampton

have 2 tables.
Questions Table:
Question ID
Date
Question

Answers Table:
Question ID
Answer

Then you can make as many answers as you like as long as the Question ID is
for your question

This make sense?

Andrew

- Original Message -
From: Marius Pertravèius [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, July 08, 2001 12:31 PM
Subject: [PHP] Polls


 Sveiki, php-general,

   I'm making some kinf of poll system. I want to use mysql table like
 this:
  date
  question
  answer1
  answer2
  answer3
  .
  answern

   but how to do this table. To write new fields isn't very good. So,
   is there any better way?



 
  2001.07.08, sekmadienis
  Marius Pertravèius
  [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Polls

2001-07-08 Thread Aaron Bennett

Marius,
   2 tables (or more) is definatly the way to approach this... I'd also add
an answerId column in the Answer table as well so you can primary key it..
for instance.

CREATE TABLE questions (
 questionId INT NOT NULL,
 date DATETIME,
 question TEXT,
 questionDesc TEXT,
 PRIMARY KEY questionId
) ;

CREATE TABLE answers (
 answerId INT NOT NULL,
 questionId INT NOT NULL,
 answer INT NOT NULL,
 PRIMARY KEY answerId
) ;

all you have to do then is SELECT answerId,answer FROM answers WHERE
questionId=$phpQuestionId.

and thats about it... the 'answers.answer' column could be another type if
you dont want and int.. I suggest using that rather than an enum just in
case you want 26+ answers to a question... You could use a char or varchar
if you like...  I also didn't include a date column in the answers table
because in the application's sense, they should be tied to the same date..
afterall, how would you design answers for your poll questions dated
differently? Also, you can put in a 'sortOrder' column if you don't want the
answers to be pulled from your db in order of the answerId or likewise.

Keep in mind how you are going to store your response... You will need
another table if you are going to capture it to a database.. You'll also
need to reference the questionId and answerId (or you can do a join with
just the answerId)...

Best of Luck!
--
Aaron Bennett

-Original Message-
From: Andrew Brampton [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 08, 2001 6:03 AM
To: Marius Pertravcius
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Polls


have 2 tables.
Questions Table:
Question ID
Date
Question

Answers Table:
Question ID
Answer

Then you can make as many answers as you like as long as the Question ID is
for your question

This make sense?

Andrew

- Original Message -
From: Marius Pertravèius [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, July 08, 2001 12:31 PM
Subject: [PHP] Polls


 Sveiki, php-general,

   I'm making some kinf of poll system. I want to use mysql table like
 this:
  date
  question
  answer1
  answer2
  answer3
  .
  answern

   but how to do this table. To write new fields isn't very good. So,
   is there any better way?



 
  2001.07.08, sekmadienis
  Marius Pertravèius
  [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]