Form processing
<p>what I'm trying to do is run a select statement for each answer to select the answer in the database where the <code>questionID = $i</code> and the <code>userID = $userID</code> so I have the query like this set up so far but not sure what I'm missing or am I right and not missing anything? Also no matter what i do both fields have values but I'm still getting the error message that I need to fill out both form fields.</p>

<pre><code>&lt;?php 
                        $i = 1;
                        while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
                        ?&gt;
                            &lt;dl&gt;

                                &lt;dt style="width: 190px;"&gt;&lt;label for="answer[&lt;?php echo $row['id']; ?&gt;]"&gt;&lt;?php echo $row['question'] ?&gt;&lt;/label&gt;&lt;/dt&gt;
                                &lt;dd&gt;&lt;input type="text" name="answer&lt;?php echo $i ?&gt;[&lt;?php echo $row['id']; ?&gt;]" size="54" /&gt;&lt;/dd&gt;

                            &lt;/dl&gt;
                        &lt;?php
                        ++$i;
                        }
                        ?&gt;

if (empty($_POST['answer1'][$i]) || trim($_POST['answer1'][$i])=="") {$errors = "yes";}
if (empty($_POST['answer2'][$i]) || trim($_POST['answer2'][$i])=="") {$errors = "yes";}

// Error checking, make sure all form fields have input
if ($errors == "yes") {

    // Not all fields were entered error
    $message = "You must enter values to all of the form fields!";

    $output = array('errorsExist' =&gt; true, 'message' =&gt; $message);

} else {

    $userID = mysqli_real_escape_string($dbc,$_POST['userID']);
    $answer1 = mysqli_real_escape_string($dbc,$_POST['answer1'][$i]);
    $answer2 = mysqli_real_escape_string($dbc,$_POST['answer2'][$i]);

    $query = "SELECT * FROM manager_users_secretAnswers WHERE questionID = '".$questionID."' AND userID = '".$userID."'";
    $result = mysqli_query($dbc,$query);
    echo $query;
</code></pre>
