gbelfast
-
Posts
1 -
Joined
-
Last visited
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Helped need with processing a Multiple Choice Quiz script (php mysql)
in PHP Coding Help
Posted
I am pretty new to using php and mysql and am struggling to understand how to go about processing a multiple choice quiz script to check if the answer given by the user is right or wrong and give the user the final result . I understand how to write and process register pages and login scripts and the like but for some reason I just can't understand what i need to do for this type of script
So far my thinking has been
1) When the page is submitted have a query that compares the answer selected to the answer in the database.
2) Have php variables for correct and and incorrect both initialised to 0 and which will change depending on the answers given.
3) Use an if else statement similar to the code below to add up the score : -
if($result['answer']==$_POST[$result['id']]){
$correct_answer++;
}else{
$incorrect_answer++;
}
4) Have a query that enters the person taking the quiz's grade in to the database.
I would really appreciate it someone could give me some guidance for the best way to do this. I have included below my code for selecting the questions form the database.