A multiple choice is pulled randomly from mysql database. Use the correct answer on the grade page
<p>I have generated a multiple choice question page, where it takes a random question from my qbanktable in my database. The CorrectAnswer to this question is also in the qbanktable. Here is the code for the question.php page</p>

<pre><code>&lt;form action="grades.php" method="post" id="quiz"&gt;
&lt;?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "qbank";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
}

$sql = "SELECT Question, AnswerA, AnswerB, AnswerC, AnswerD, AnswerE, CorrectAnswer FROM qbanktable ORDER BY RAND() LIMIT 1";
$result = $conn-&gt;query($sql);


?&gt;

                  &lt;h3&gt;
                  &lt;?php

$result = $conn-&gt;query($sql);

if ($result-&gt;num_rows &gt; 0) {
    // output data of each row
    while($row = $result-&gt;fetch_assoc()) {
        echo $row["Question"];
    }
}
       ?&gt;                  

                 &lt;/h3&gt;
                  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                  &lt;div&gt;
                        &lt;input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" /&gt;
                        &lt;label for="question-1-answers-A"&gt;A)&amp;nbsp;     
                            &lt;?php
                                $result = $conn-&gt;query($sql);
                                if ($result-&gt;num_rows &gt; 0) {
                                    while($row = $result-&gt;fetch_assoc()) {
                                        echo $row["AnswerA"];
                                        }
                                    }
                                    ?&gt;      
                        &lt;/label&gt;
                  &lt;/div&gt;

                    &lt;div&gt;
                        &lt;input type="radio" name="question-1-answers" id="question-1-answers-B" value="B" /&gt;
                        &lt;label for="question-1-answers-B3"&gt;B)&amp;nbsp;
                            &lt;?php
                                $result = $conn-&gt;query($sql);
                                if ($result-&gt;num_rows &gt; 0) {
                                    while($row = $result-&gt;fetch_assoc()) {
                                        echo $row["AnswerB"];
                                        }
                                    }
                                    ?&gt;  
                        &lt;/label&gt;
                    &lt;/div&gt;

                    &lt;div&gt;
                        &lt;input type="radio" name="question-1-answers" id="question-1-answers-C" value="C" /&gt;
                        &lt;label for="question-1-answers-C3"&gt;C)&amp;nbsp;
                            &lt;?php
                                $result = $conn-&gt;query($sql);
                                if ($result-&gt;num_rows &gt; 0) {
                                    while($row = $result-&gt;fetch_assoc()) {
                                        echo $row["AnswerC"];
                                        }
                                    }
                                    ?&gt;  
                        &lt;/label&gt;
                    &lt;/div&gt;

                    &lt;div&gt;
                        &lt;input type="radio" name="question-1-answers" id="question-1-answers-D" value="D" /&gt;
                        &lt;label for="question-1-answers-D3"&gt;D)&amp;nbsp;
                            &lt;?php
                                $result = $conn-&gt;query($sql);
                                if ($result-&gt;num_rows &gt; 0) {
                                    while($row = $result-&gt;fetch_assoc()) {
                                        echo $row["AnswerD"];
                                        }
                                    }
                                    ?&gt;  
                        &lt;/label&gt;
                    &lt;/div&gt;
                     &lt;div&gt;
                        &lt;input type="radio" name="question-1-answers" id="question-1-answers-D" value="E" /&gt;
                        &lt;label for="question-1-answers-D3"&gt;E)&amp;nbsp;
                            &lt;?php
                                $result = $conn-&gt;query($sql);
                                if ($result-&gt;num_rows &gt; 0) {
                                    while($row = $result-&gt;fetch_assoc()) {
                                        echo $row["AnswerE"];
                                        }
                                    }
                                    ?&gt;  
                        &lt;/label&gt;
                    &lt;/div&gt;
                    &lt;div&gt;
                    &lt;input type="hidden" name="question-1-correct_answer" id="question-1-correct-answer" value="$row["CorrectAnswer"]" &gt;
                &lt;/div&gt;
          &lt;/ol&gt;

            &lt;input type="submit" class="hvr-grow" value="SUBMIT" /&gt;
    &lt;/form&gt;
</code></pre>

<p>Now after I press the submit button, it will direct me to grades.php where it will analyze the CorrectAnswer:</p>

<pre><code>        &lt;?php
        $correctAnswer = $_POST['question-1-correct_answer'];
        $answer1 = $_POST['question-1-answer'];

        if ($answer1 == $correctAnswer) {

        echo "&lt;img src=correct.svg";
        }
        else {
        echo "&lt;img src=wrong.svg";
        }
        ?&gt;
</code></pre>

<p>I believe now in the grades.php (code above) I am messing something simple. I was wondering what is the correct code to match the CorrectAnswer with the user answer? Thank you</p>