Jump to content

while (list($a, $b, $c, $d) = each($e)) {


Donovan

Recommended Posts

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 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)

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/85360-while-lista-b-c-d-eache/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.