从动态表单插入多个数组

I have been trying to work with this code to get two arrays to insert into the sql db. The data is coming from a form that is generated from an sql table. My original intention was to update a the table where the form was generated from questions and answers. However I beleive it would be easier to just insert them into a new table and when the info is needed I can call from that table. Either way though there are two important piecesofinformationthat hae to be transfered and line up exactly. Those are the row in which the question is from and the interview id that the question is being attached to. Here is my code.

 $result = mysql_query("SELECT * FROM interviews WHERE id='$int'");
                        while($row = mysql_fetch_array($result)){ $a = $row[1]; $b =   $row[2]; $c = $row[3]; $d = $row[4]; $e = $row[5]; $f = $row[7]; $g = $row[8]; $h = $row[9]; }

                    $i = array();   
                    $result = mysql_query("SELECT * FROM dbinter WHERE interview_id='$int'");
                        while($row = mysql_fetch_array($result)){ $i[] = $row[2]; }

                    $l = array();   
                    $result = mysql_query("SELECT * FROM form_custom WHERE attached='$cid' && date='$e'");
                        while($row = mysql_fetch_array($result)){ $l[] = $row[0]; }

                    echo "<font style='font-size: 45px;'>$a $b</font>";

                                    echo "<p><font style='font-size: 20px;'>$c
                                    <br />$d</font></p>";

                    echo "<form method='POST' name='interview' action='interviewsheet.php?cid=$cid&int=$int&stat=proc'>";
                    echo "<div style='margin-top:50px;'><input type='submit' value='COMPLETE INTERVIEW'></div>";

                    foreach($i as $j){
                    $result = mysql_query("SELECT * FROM form WHERE id='$j'");
                    while($row = mysql_fetch_array($result)){ $k = $row[2]; $p = $row[0];}
                    echo "
                    <div style='margin: 20px;'>
                    <font styler='font-size: large; font-weight: bold;'>$k</font><br />
                    <textarea rows='5' cols='60' style='border: none;' name='q'></textarea>
                    <input type='hidden' name='qid' $value='$p'>
                    </div>
                    ";}

                    foreach($l as $m){
                    $result = mysql_query("SELECT * FROM form_custom WHERE id='$m'");
                    while($row = mysql_fetch_array($result)){ $n = $row[2]; $q = $row[0];}
                    echo "
                    <div style='margin: 20px;'>
                    <font styler='font-size: large; font-weight: bold;'>$n</font><br />
                    <textarea rows='5' cols='60' style='border: none;' name='qc'></textarea>
                    <input type='hidden' name='qcid' $value='$q'>
                    </div>
                    ";}
                    echo "</div>";

}

the other code for the processing page is:

    $a = array();
    $a[] = $_POST['q'];
    $b = array();
    $b[] =$_POST['qc'];
    $e = array();
    $e[] = $_POST['qid'];
    $f = array();
    $f[] = $_POST['qcid'];

    $frm = "f";
    $frmc = "fc";


    foreach($a as $key=>$value){
        $avalue = mysql_real_escape_string($value);
        $evalue = mysql_real_escape_string($e[$key]);
        $sql = "INSERT INTO answers (qid,cid,inta,frm,ans) VALUES ('$evalue','$cid','$int','$frm','$avalue')";
                if (!mysql_query($sql,$con)){die('Error: ' . mysql_error());}
    }

    foreach($b as $key=>$value){
        $bvalue = mysql_real_escape_string($value);
        $fvalue = mysql_real_escape_string($f[$key]);
        $sql = "INSERT INTO answers (qid,cid,inta,frm,ans) VALUES ('$fvalue','$cid','$int','$frmc','$bvalue')";
                if (!mysql_query($sql,$con)){die('Error: ' . mysql_error());}
    }





    header("Location: hr.php?act=int&stat=pend");

    }

What you're doing here is setting an array to be the first element of an array.

$a = array();
$a[] = $_POST['q'];
$b = array();
$b[] =$_POST['qc'];
$e = array();
$e[] = $_POST['qid'];
$f = array();
$f[] = $_POST['qcid'];

So $a will then be a single element in length and that is then an array equal to $_POST['q']

I agree with the comments above about the code used etc, but sticking this in instead of the code above will get you a loopable array...

$a = (array)$_POST['q'];
$b = (array)$_POST['qc'];
$e = (array)$_POST['qid'];
$f = (array)$_POST['qcid'];