I was using a foreach($_POST['a'] as $key => $value) {
to process a loop, but have another issue. I have more than two values I am trying to pass to another page to process and the $key => $value isn't enough.
I actually have 4 values for each record. I pull this from a query:
$studentYearlist = $db->sql_query("SELECT * FROM ".$prefix."_tl_students a
JOIN ".$prefix."_tl_group_students b ON a.SOMS_KEY = b.SOMS_KEY
WHERE a.Class_Year = $Course_Year");
while ($row = $db->sql_fetchrow($studentYearlist)) {
$SOMS_KEY = $row['SOMS_KEY'];
$Name_First = $row['Name_First'];
$Name_Last = $row['Name_Last'];
$UID = $row['U_Account'];
$Group_ID = $row['Group_ID'];
if (!$studentYearlist) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
I was loading the _POST array like this.
"<td><input type='text' name='IRAT_Grade[{$SOMS_KEY}]' size='3' maxlength='3'></td>"
So each grade would have a corrosponding SOMS_KEY value.
But I also have $Group_ID, and $UID for each record.
Is it possible for me to do this?
. "<td><input type='text' name='IRAT_Grade[{$SOMS_KEY}]' size='3' maxlength='3'></td>"
. "</tr>"
. "<input type='hidden' name='IRAT_Grade[{$Group_ID}]' value='$Group_ID'>\n"
. "<input type='hidden' name='IRAT_Grade[{$UID}]' value='$UID'>\n";
Then on the processing page do something like:
while (list($SOMS_KEY, $IRAT, $Group_ID, $UID) = each($IRAT_Grade)) {
$sql = "INSERT INTO ".$prefix."_tl_session_grades (Session_ID, UID, Group_ID, SOMS_KEY, IRAT_Grade, Academic_Year)". "VALUES ('$Session_ID', '$UID', '$Group_ID', '$SOMS_KEY', '$IRAT', '$Academic_Year')";
$result = $db->sql_query($sql);
if (!$result) {echo("<p>Error performing query: " . mysql_error() . "</p>");}
}
I think I would have to POST the values somewhere as well same as I did here: foreach($POST['a'] as $key => $value)