Thanks to the folks who provided helpful pointers. After a short break from the project, I was able to look at it with fresh eyes, and I think I have the answer. It's working for me, anyway.
// grab the names of the special requirements
$specialRequirementNamesQuery = "SELECT DISTINCT SpecialRequirementName
FROM SpecialRequirements
ORDER BY SpecialRequirementName;" ;
$specialRequirementNames = mysql_query($specialRequirementNamesQuery)
or die(mysql_error());
// create the checkboxes
while ($srn = mysql_fetch_array($specialRequirementNames)) {
echo "<input type='checkbox' name='SpecialRequirementName[]' value='"
. $srn['SpecialRequirementName'] . "' ";
// grab the names of the special requirements that are selected for this student
$selectedSpecialRequirementsQuery = "SELECT SpecialRequirementName
FROM SpecialRequirementAssignments
WHERE StudentID = '" . $StudentID . "';" ;
$selectedSpecialRequirements = mysql_query($selectedSpecialRequirementsQuery)
or die(mysql_error());
// compare the special requirement name to the selected special requirements
// if they're the same, check the box
while ($checkedBoxes = mysql_fetch_array($selectedSpecialRequirements)) {
if(strcmp($srn['SpecialRequirementName'], $checkedBoxes['SpecialRequirementName'])==0) {
echo "checked";
}
}
echo " /> " . $srn['SpecialRequirementName'] . "<br>";
}