Help Me On This Please!
Guess you know or hard of Cisco online examinations!
In my project am to implement some thing of that kind! i have done most and one part still failing where i need you help!
With lots of questions in a database each with a subject, 4 different objective answers,with the right Ans and a year of the question it was examined in an examination board. when some body selects the subject and year to do, then the respective questions are displayed using the while loop with for the sql statement
Well i can have all the questions displayed with there objective ans choices but after one submits the paper how should i start marking the questions to determine the right and wrongs meaning i can identify each question!
$sql = mysql_query("select * from questions where Subject = '$subject' and Year = '$year'")
Please Help me thanks
If I understand you correctly, you have a subject on the test, under the subject you have several questions, under each question you have 4 different possible answers, and your question is, "How can I tell with the PHP script and mySQL which answer is the RIGHT one."
Do I understand you correctly?
Alright... Here is what I would do.
One table for each; the subject, the questions, the answers:
Then in the form, use the identification numbers from the records for the values on the test. Then to test for the corrrect answer on a question, you would run a query like this:
CREATE TABLE tblSubject (
fldSubjectId SMALLINT(5) AUTO_INCREMENT UNSIGNED ZEROFILL,
fldSubject VARCHAR(the maximum length you think you will need),
PRIMARY KEY (fldSubjectId));
CREATE TABLE tblQuestions (
fldQuestionId MEDIUMINT AUTO_INCREMENT UNSIGNED ZEROFILL,
fldSubjectId SMALLINT(5) UNSIGNED ZEROFILL,
fldQuestion VARCHAR(the maximum length you think you will need),
PRIMARY KEY (fldQuestionId));
CREATE TABLE tblAnswers (
fldAnswerId MEDIUMINT AUTO_INCREMENT UNSIGNED ZEROFILL,
fldQuestionId MEDIUMINT UNSIGNED ZEROFILL,
fldAnswer VARCHAR(the maximum length you think you will need),
PRIMARY KEY (fldAnswerId));
SELECT fldCorrect FROM tblAnswer WHERE fldQuestionId = [whatever variable you use to assign the question id to];