Q:

How to compare value of a dynamically created radio button

I am dynamically generating a set of radio buttons from MySQL.  The buttons are creating and the variables assigned to them are populating as I did an echo print_r and it shows the array for the variable.  I now want to compare the values generated from this and if the vale is "0" I want to insert a score and present a green check graphic and the word correct.  If the value is "1" I want it to input different values for the score and present Incorrect and a red X graphic.  Here is what I have so far (Everything populates dynamically both the question and the answers as radio buttons):
<? php
echo '<form id="frmQuestion" name="frmQuestion" method="post" action="QuizQuestion1.php">';

// Connect to the Database
require_once('mysqli_connect.php');

//create the query for the question
$q = "SELECT `Question` FROM tbl_Question WHERE QuestionID = 1";

//Create the query for the Answers
$q2 = "SELECT `Answer`,`AnswerStatusID`,`AnswerResponse` FROM tbl_Answer WHERE QuestionID = 1";

//Run the query
$r = mysqli_query($conn,$q);

//run the answer query
$r2 = mysqli_query($conn,$q2);

while($row = mysqli_fetch_array($r,MYSQLI_ASSOC)){
    echo '<div id="Question1"><p> ' .  $row['Question'] . ' </div></p>';
}

//Declare the variables as a array
$AnswerResponse = array();
$AnswerStatusID = array();

while($row2 = mysqli_fetch_array($r2,MYSQLI_ASSOC)){
    echo '<div id="Question1"><input name="q1" type="radio" value="'.$AnswerStatusID.'"/>' .  $row2['Answer'] . ' </div><br/>';

    //Assign the AnswerStatusID to a var
    $AnswerStatusID[] = $row2['AnswerStatusID'];

    //Assign the AnswerResponse to a var
    $AnswerResponse[] = $row2['AnswerResponse'];
}

//Create the submit button 
echo '<input type="submit" value="Submit Answer" name="submit"/>';
echo '</form>';

//Logic for correct or incorrect answers
if (isset($_POST['q1']) && ($_POST['q1'] == '0'))
{
    //create the query for the score
    $q3 = "INSERT INTO tbl_Score (`Score`,`QuestionID`) VALUES ('100%','1')";   

    //Run the query 
    $r = @mysqli_query ($conn,$q3);

    if($r){

        //Confirm message data was entered with a correct response and a graphic
        echo '<h1>Correct!!</h1><img src="/images/green_Check_Low.jpg" alt="Green Check"/>';
        echo '<a href="QuizQuestion2.php">Click here for the next question</a>';
    }
    else
    {
        //there was an error
        echo'<h1>System error</h1>';

        //Debugging message
        echo'<p>' .  mysqli_error($conn) . ' <br/><br/>Query:' .  $q3 . ' </p>';

    }//End of nested IF
}
else{
    //create the query for the score
    $q4 = "INSERT INTO tbl_Score (`Score`,`QuestionID`) VALUES ('0%','1')"; 

    //Run the query 
    $r2 = @mysqli_query ($conn,$q3);

    if($r2){

        //Confirm message data was entered with a correct response and a graphic
        echo '<h1>Incorrect!!</h1><img src="/images/red_X_Low.jpg" alt="Red X"/>';
        echo '<a href="QuizQuestion2.php">Click here for the next question</a>';
    }
    else
    {
        //there was an error
        echo'<h1>System error</h1>';

        //Debugging message
        echo'<p>' .  mysqli_error($conn) . ' <br/><br/>Query:' .  $q3 . ' </p>';

    }//End of nested IF

}

//Free up the results for the Question query
mysqli_free_result($r);

//Free up the results from the Answer query
mysqli_free_result($r2);

//close the DB connection
mysqli_close($conn); 

? >

A:

This is the answer and work as intended.  Thanks for everyones input.    
//Declare the variables as a array
$AnswerResponse = array();
$AnswerStatusID = array();

while($row2 = mysqli_fetch_array($r2,MYSQLI_ASSOC)){
echo '<div id="Question1"><input name="q1" type="radio" value="'.$row2['AnswerStatusID'].'"/>' .  $row2['Answer'] . ' </div><br/>';

//Assign the AnswerStatusID to a var
$AnswerStatusID[] = $row2['AnswerStatusID'];

//Assign the AnswerResponse to a var
$AnswerResponse[] = $row2['AnswerResponse'];
}

//Create the submit button 
 echo '<input type="submit" value="Submit Answer" name="submit"/>';
echo '<input type="hidden"name="submitted"value="TRUE"/>';
echo '</form>';

if($_POST['submitted']) { 

//Logic for correct or incorrect answers
if (isset($_POST['q1']) && ($_POST['q1'] == '0'))
{
//create the query for the score
$q3 = "INSERT INTO tbl_Score (`Score`,`QuestionID`) VALUES ('100%','1')";   

//Run the query 
$r3 = @mysqli_query ($conn,$q3);

//Confirm message data was entered with a correct response and a graphic
echo '<h1>Correct!!</h1><img src="/images/green_Check_Low.jpg" alt="Green Check"/>';
echo '<a href="QuizQuestion2.php">Click here for the next question</a>';

}       
else{
//create the query for the score
$q4 = "INSERT INTO tbl_Score (`Score`,`QuestionID`) VALUES ('0%','1')"; 

//Run the query 
$r4 = @mysqli_query ($conn,$q4);

//Confirm message data was entered with a correct response and a graphic
echo '<h1>Incorrect!!</h1><img src="/images/red_X_Low.jpg" alt="Red X"/><br/>';
echo '<a href="QuizQuestion1.php">Click here to try again</a>';

}

}

