Hello everyone! I'm new to these forums so please take it easy if I'm not doing this correctly.
My problem seems to be a simple one but I can't seem to get my brain around it. I have a database that contains different classes that employees must complete. In each row of the database the record stores things like the class name, due dates and so forth. In order to see what employees need to take that class I created a field for each employee in this record that saves a value Y or N. If the value is Y then that specific employee needs to take the class, alternatively if the value is N then the employee does not have to take the class.
I'm using PHP to try and get the values out of the database and display them to checkboxes. This is the code I have:
<?php
$titleQuery = "SELECT * from aci_job_titles";
$titleResult = mysql_query($titleQuery);
if ($titleResult)
{
while($titleKey = mysql_fetch_array($titleResult))
{
print "<input type='checkbox' name='titles' onclick='changeHiddenValue(" . $titleKey['ID'] . ", class_form)' value='" . $titleKey['jobTitle'] . "'";
if ($titleKey['apManager'] == 'Y') {print " checked";}
else if ($titleKey['csRep'] == 'Y') {print " checked";}
else if ($titleKey['hrManager'] == 'Y') {print " checked";}
print ">" . $titleKey['jobTitle'] ."</option><br/>";
}
}
?>
If one of the employee titles is Y then it seems all of the checkboxes get checked.
Does anyone have a better way of doing this? Thanks in advance.