I'm doing a online exam tool. I want to minimize the number of database requests. So I am requesting all the questions in the test at one go. After this I have to remember all the questions user has attempted and their answers. My plan is to save the answers in a php session variable like this
$('input[type=radio]').click(function()
{
var id = ($(this).parent().attr('id'));
id = id.slice(4);
$('#nav'+id).css('color','red');
<?php $_SESSION['ques['id']']= ?> $(this).val() <?php ;?>
});
In the above code the following lines are to change the color of attempted questions.
var id = ($(this).parent().attr('id'));
id = id.slice(4);
$('#nav'+id).css('color','red');
Here id is the id of the question. Problem is I'm getting the following error
Parse error: syntax error, unexpected ';' in /var/www/sites/onlinetest/test.php on line #x
Also I'm pretty sure the following is wrong
$_SESSION['ques['id']']
since id is the javascript variable here. Please help me. Also I appreciate if any other better solution than 'storing in the session variables' is posted