Multidimensional POST array giving me grief
Posted: Wed Mar 31, 2010 11:06 am
I have a form that is a list populated by every student name, course name, etc. and a checkbox from a database. I want to be able to check selected records in the list, then perform an action on the selected records upon POST. I understand that the result I get from POST is a multidimensional array, but I can't figure out how to extract the records. I am posting an abreviated version of the code below. I think the form is OK. It's extracting the POST data that is driving me nuts. Thanks for any thoughts.
Code: Select all
<?php
if ($_POST['submit']){
foreach($_POST [delete_student] as $d) {
echo $d[student_id][$row];
echo $d[student_id][$row];
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="submit" value="SUBMIT"/>
<?php
$eRow = 0;
while ($user = mysql_fetch_assoc($sql)) {
$iRow++;
<input name="delete_student[<?php echo $eRow ?>]" type="checkbox" value="1" />
<?php echo $Name?>
<input name="student_id[<?php echo $eRow ?>]" type="hidden" value="<?php echo $user['student_id'];?>"/>
<input name="course_id[<?php echo $eRow ?>]" type="hidden" value="<?php echo $course_id ?>"/>
<?php
}
?>
</form>