do you have a database or file of the correct answers (answer sheet of the certain questionnaire)

It can be implemented as an online examination system. And yes the display of the answers should be displayed as u have mentioned before. that is:

In my Question Number 1 your answer is... Choice number 2
In my Question Number 2 your answer is... Choice number 1

and gives the score.

My problem was implementing the same using the arrays.

No i dont have a file or a database of the correct answers. i was opting to use just the answers...

And may be implement it using the if statements....

go back to previous page where you loop the select tag for answers, right now back track the loops of questions and place inside the label tag with the name="questions_array[]" and the value='".$v['questions']."'
so it will look like this
echo "<label name='questions_array[]' value='".$v['questions']."'>".$v['questions']."</label></br/>";

after what I had mentioned before this.
do the same thing of printing the array using print_r and check again if there's no error just like what you did in print_r($_POST['selected_answers']);
now do this also
print_r($_POST['questions_array']);
trigger it and see if the correct questions are also passed down to processor.php

when I try to run my code after doing that it erases my questions and displays only the answers on the browser.

It displays the answers only...

ohh so I got it. there's no error on that but label tag does not support on passing down it's content. Kindly stay tuned for about 2 hours. because I'm off now at work and see you later after 2 hrs

Ok, I will be waiting. Thank you.

After inserting the codes it only displays:

Array ( [0] => risk management [1] => control coupling [2] => beta testing [3] => Stress testing [4] => Stress testing [5] => Achieng ) 

Hi! I'm still online

I hope tomorrow we continue with the coding. This is where we left:

<?php
//If we submitted the form
if (isset($_POST['submit']))
{
print_r($_POST['selected_answers']);
}
?>

Was suppose to accomplish:

Its task will be to check the answers chosen, among them there is one correct one and others are wrong. Processor.php should compute by adding one for each correct answer and adding zero for the wrong answers and at the end give out the verdict out of the total number of questions. Thank you once again.

I'm sorry I havent got back as what I've said yesterday. Dont use label on your previous page because it will not pass down the content.

first on your previous page ( before the process.php )

place this css tag down below the opening head tag

<style>
#text_disabled{
border:none;
font-size:10pt;
color:black;
}
</style>

now after placing the style replace the label tag with
Last name: <input id='text_disabled' type='text' value='".$v['question']."' name='questions[]' disabled>
you see there was 'disabled' on the part of the text box, meaning cannot be edited. so in this manner value attribute is the one that automates to insert the question to the question[] you dont have to enter the values anymore.

then on your process.php you can now proceed by print_r($_POST['questions']); and now you can be able to pass it on

I have tried to do as u have said it works so well but there are problems with the display when i run the codes:

1) The questions are being overllaped by the pull down menu for answers such that some parts of the questions cannot be viewed.
2) processor.php doesn't display the questions as u have said.

Thanks you.

I have managed to solve the overlapping elements of questions and answers:
Now what remains is that the processor.php does not display the questions as u had said.
thank you.

Hi it's been a couple of hours

kindly lrtme know where your print_r($_POST['questions']) was coded and run it once more.

Its still not displaying the questions.

It was coded in the following manner in the processor.php

<?php
print_r($_POST['questions']);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.