I have a table with a lot of checkboxes. The checkboxes are being produced via a loop, and are given a unique id.
$get_depts = mysql_query("select dept_id, dept_name from depts where bus_id = '{$business['bus_id']}'");
while(($department = mysql_fetch_assoc($get_depts)))
{
echo '<tr><td>'.$department['dept_name'].'</td>';
$req_fields = mysql_fetch_assoc(mysql_query("SELECT employees, department, customer, salespeople, acct_nbrs, categories, subcategories, case_ids, login_ids, phone, phext, cust_email, problem, resolution, source, priority FROM required_fields WHERE dept_id = '{$department['dept_id']}'"));
if($req_fields['employees'] == 'YES'){echo '<td><input type="checkbox" id="employees[]" name="employees[]" value="YES" checked></td>';}
else echo'<td><input type="checkbox" id="employees[]" name="employees[]" value="YES"></td>';
}
As you can see, one such example of the id and name of a checkbox is employees1, employees2, etc.
After submit, I try and loop back through my departments to pick up the unique id numbers again. Then I try and update my table.
$get_depts = mysql_query("select dept_id, dept_name from depts where bus_id = '{$business['bus_id']}'");
while(($department = mysql_fetch_assoc($get_depts)))
{
mysql_query("Update required_fields set employees = '{$_POST['employees'.$department['dept_id']]}' where dept_id = '{$department['dept_id']");
}
I obviously am not using the correct syntax for the post variable. How can I correctly use $_POST['employees'] + $department['dept_id']?
EDIT
The FINAL result would look like this. If $department['dept_id'] = 10 for example, then the name of the post variable would be $_POST['employees10']