Jump to content

Split: PHP/MySQL Multiple Choice Quiz Logic


tenar

Recommended Posts

Hi, sorry for bumping this thread. I have a question regarding your code. I'm pretty new to any kind of coding. In this line: 

<input type="radio" name="answer[<?php echo $result['id'] ?>]" value="A"> <?php echo $result['answerA']; ?> <br>

 

 

what is the value assigned to the name in the end. name="answer"    or     name="answer$id" or something else.

Names would look like answer[$id]

eg

<form action="" method="get">
Q1. Do you know which?<br>
<input type="radio" name="answer[1]" value="A">A - Answer A<br>
<input type="radio" name="answer[1]" value="B">B - Answer B<br>
<input type="radio" name="answer[1]" value="C">C - Answer C<br>
<input type="radio" name="answer[1]" value="D">D - Answer D<br>
<br><br>
Q2. What is the answer?<br>
<input type="radio" name="answer[2]" value="A">A - Answer A<br>
<input type="radio" name="answer[2]" value="B">B - Answer B<br>
<input type="radio" name="answer[2]" value="C">C - Answer C<br>
<input type="radio" name="answer[2]" value="D">D - Answer D<br>
<br><br>
<input type="submit" value="Submit" name="btnSubmmit">
</form>

So when posted would look like this (depending on the answers selected)

 

Array
(
    [answer] => Array
        (
            [1] => B
            [2] => D
        )

    [btnSubmmit] => Submit
)

hope that helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.