Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.