Maybe this sample is closer to what you need.
<?php
if(isset($_POST['submit'])):
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
if(isset($_POST['absence']) || isset($_POST['late'])):
include $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/db.inc.php';
try
{
foreach($_POST['student'] as $key => $studentID):
if(array_key_exists($key,$_POST['absence']) || array_key_exists($key,$_POST['late'])):
$studentid = $_POST['student'][$key];
$courseid = $_POST['course'][$key];
$absence = (array_key_exists($key,$_POST['absence']) ? $_POST['absence'][$key] : '0');
$late = (array_key_exists($key,$_POST['late']) ? $_POST['late'][$key] : '0');
$sql = 'INSERT INTO notes SET
userid = :studentid
, courseid = :courseid
, date = CURDATE()
, late = :late
, absence = :absence';
$s = $pdo->prepare($sql);
$s->bindParam(':studentid', $studentid);
$s->bindParam(':courseid', $courseid);
$s->bindParam(':absence', $absence);
$s->bindParam(':late', $late);
$s->execute();
endif;
endforeach;
}
catch (PDOException $e)
{
$error = 'Error adding submitted daily notes data. Click the back button to continue.';
include 'error.html.php';
exit();
}
header('Location: .');
exit();
endif;
endif;
?>
<form action="" method="post">
<table>
<tr>
<th>Course</th>
<th>Student</th>
<th>Absence</th>
<th>Late</th>
</tr>
<?php $x = 1;?>
<?php foreach (array_reverse($courses) as $course):
foreach (array_reverse($learners) as $learner): ?>
<?php if($course['id']==$learner['courseid']): ?>
<tr>
<td>
<?php htmlout($course['course']) ?>
</td>
<td>
<?php htmlout($learner['learner']);?>
</td>
<td>
<input type="hidden" name='course[<?php echo $x; ?>]' value="<?php htmlout($course['id'])?>">
<input type="hidden" name='student[<?php echo $x; ?>]' value="<?php htmlout($learner['courseid']);?>">
<input type="checkbox" name="absence[<?php echo $x; ?>]" value="1">
</td>
<td>
<input type="checkbox" name="late[<?php echo $x; ?>]" value="1">
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php $x++;?>
<?php endforeach; ?>
</table>
<input type="submit" name="submit" value="Submit">
</form>