Greetings: I'm working on a form where a client can schedule their employees for work. The idea is that there will be a table with the employee names going down one column, and then for each day going off to the right, there's two checkboxes for day shift and night shift. The manager can then check the box for when each employee will work and hit submit. The problem is, I'm not sure how to handle this form. Can anybody give me an idea as to how I could name the checkboxes so that I can process the results on the following page and submit it to the database? Any tips, suggestions, help would be greatly appreciated!
you can create the checkboxes like a vector: <input type="checkbox" name="employerSchedule[EMPLOYERID-DATE-SHIFT]" value="1"> Code (markup): So you can replace EMPLOYERID for the employer id, of course, the date for the date and the shift for something like a number (1=day shift, 2=night shift), so ex: <input type="checkbox" name="employerSchedule[122-13052010-1]" value="1"> Code (markup): That would mean, if that checkbox is checked, that employer 122, on 13/05/2010, is going to have a day shift. Something like that. On server side, if you use a foreach like: foreach($_POST['employerSchedule'] as $id=>$k) { } Code (markup): at each iteration, the variable $id would have the information inside the brackets, like in the example, 122-13052010-1. Now you can treat that string and do what you want. Hope it helps you.