Quote
QuestionID,
EffectiveDateTime,
QuestionText,
CorrectAnswerText
Quote
AnswerID,
QuestionID,
AnswerText,
AnswerDateTime,
UserID (From Users table)
Quote
SELECT COUNT(*), username
FROM users u
INNER JOIN Answers a ON a.UserID = u.UserID
INNER JOIN Questions q ON q.QuestionID = a.QuestionID
AND q.CorrectAnswerText = a.AnswerText
WHERE
q.QuestionID = ???
GROUP BY username
HAVING COUNT(*) > 0
ORDER BY COUNT(*)
CREATE TABLE oscars2013 (
id int(11) NOT NULL auto_increment,
name varchar(64),
email varchar(96),
picture varchar(24),
director varchar(24),
actor varchar(24),
actress varchar(4),
supactor varchar(24),
supactress varchar(24),
origscreen varchar(24),
adaptscreen varchar(24),
animfeature varchar(24),
forfilm varchar(24),
cinematography varchar(24),
editing varchar(24),
artdir varchar(24),
design varchar(24),
makeup varchar(24),
origscore varchar(24),
origsong varchar(24),
sndmixing varchar(24),
sndediting varchar(24),
viseffects varchar(24),
docufeature varchar(24),
docushort varchar(24),
animshort varchar(24),
actionshort varchar(24),
PRIMARY KEY (id)
);
Quote
Table: Questions
QuestionID,
EffectiveDateTime,
QuestionText,
CorrectAnswerText,
RelatedFieldName
Quote
1,
NOW(),
"What is my favourite oscar's e-mail address?",
"None",
"email"
Quote
$my_sql = "
SELECT COUNT(*), username
FROM users u
INNER JOIN Answers a ON a.UserID = u.UserID
INNER JOIN Questions q ON q.QuestionID = a.QuestionID
WHERE q.QuestionID = 1
INNER JOIN (
SELECT *, a.QuestionID
FROM Oscar2013
WHERE ".$field_name." = ".$_POST['my_answer']."
) AS a ON a.QuestionID = q.QuestionID
GROUP BY username
HAVING COUNT(*) > 0
ORDER BY COUNT(*)
";
Quote
SELECT RelatedFieldName FROM Questions WHERE QuestionID = 1
Quote
ronald1985 wrote:
Are these questions stored in a database?
I will come up with some code.
Quote
<?php
if(isset($_POST) && count($_POST) > 0) {
mysql_connect('localhost';
mysql_select_db('testing';
foreach($_POST as $key => $value) {
if(!in_array($key, array('Submit', 'email', 'name')) {
$sql = '
INSERT INTO Answers (
QuestionText,
AnswerText,
Name,
EmailAddress,
DateTime
)
SELECT "'.$key.'", "'.$value.'", "'.$_POST['name'].'", "'.$_POST['email'].'", NOW()
';
mysql_query($sql);
}
}
mysql_close();
echo 'Done.'
}
?>
Quote
AnswerIdentity INT AI
QuestionText VARCHAR(50)
AnswerText VARCHAR(50)
Name VARCHAR(50)
EmailAddress VARCHAR(50)
DateTime DATETIME
Quote
SELECT COUNT(*) AS RowCount, Name, EmailAddress, QuestionText
FROM Answers
WHERE (
(QuestionText = 'actress' AND AnswerText = 'Jessica Chastain for Zero Dark Thirty'
OR
(MORE CRITERIA HERE)
OR
...........
)
GROUP BY Name, EmailAddress, QuestionText
ORDER BY COUNT(*) DESC
Quote
OR
(MORE CRITERIA HERE)
OR
...........
Category Forum
General DiscussionLabels
None yet
Statistics
2 participants
Notifications
You are not receiving notifications from this thread.
Related Questions