ChrisF79 Posted May 2, 2010 Share Posted May 2, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/200462-help-me-with-a-scheduling-app/ Share on other sites More sharing options...
maxudaskin Posted May 2, 2010 Share Posted May 2, 2010 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! Make a chart, design the form, and upload here. Hopefully before you upload, you'll have a eureka moment, but if you don't, at least we'll have something to work with. Quote Link to comment https://forums.phpfreaks.com/topic/200462-help-me-with-a-scheduling-app/#findComment-1051997 Share on other sites More sharing options...
ignace Posted May 2, 2010 Share Posted May 2, 2010 <input type="checkbox" name="employees[<?php print $id ?>]"> Quote Link to comment https://forums.phpfreaks.com/topic/200462-help-me-with-a-scheduling-app/#findComment-1052019 Share on other sites More sharing options...
litebearer Posted May 2, 2010 Share Posted May 2, 2010 hmmm Old guy musing... the form... <form action="schedule01.php" method="post"> <table border="1"> <tr> <td>emp name</td> <td>Sun</td> <td>Mon</td> <td>Tue</td> <td>Wed</td> <td>Thu</td> <td>Fri</td> <td>Sat</td> </tr> <?PHP ################################## # begin looping thru the employee table ################################## $employee = array ("Jim Jones|23", "Mark Smith|2", "Tracy Thompson|532"); $count_emp = count($employee); $i=0; while($i<$count_emp) { /*get the employee name and id */ $temp_array = explode("|", $employee[$i]); $temp_name = $temp_array[0]; $emp_id = $temp_array[1]; ?> <tr> <td><?PHP echo $temp_name . "<br>" . $emp_id; ?></td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_sun"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_sun"; ?>" value="night"></td> </tr> </table> </td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_mon"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_mon"; ?>" value="night"></td> </tr> </table> </td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_tue"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_tue"; ?>" value="night"></td> </tr> </table> </td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_wed"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_wed"; ?>" value="night"></td> </tr> </table> </td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_thu"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_thu"; ?>" value="night"></td> </tr> </table> </td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_fri"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_fri"; ?>" value="night"></td> </tr> </table> </td> <td> <table> <tr> <td>day</td> <td><input type="radio" name="<? echo $emp_id . "_sat"; ?>" value="day" checked></td> </tr> <tr> <td>night</td><td><input type="radio" name="<? echo $emp_id . "_sat"; ?>" value="night"></td> </tr> </table> </td> </tr> <?PHP $i++; } ?> </table> <input type="submit" value="Submit"> </form> (Preview of form output here http://www.nstoia.com/projects/working/misc_scripts/schedule00.php ) The processing file (NOTE - Still trying to wrap my head around dynamically handing the POST) <?PHP $employee = array ("Jim Jones|23", "Mark Smith|2", "Tracy Thompson|532"); $count_emp = count($employee); $i=0; while($i<$count_emp) { $temp_array = explode("|", $employee[$i]); $temp_name = $temp_array[0]; $emp_id = $temp_array[1]; $sun01 = $emp_id . "_sun"; $mon01 = $emp_id . "_mon"; $tue01 = $emp_id . "_tue"; $wed01 = $emp_id . "_wed"; $thu01 = $emp_id . "_thu"; $fri01 = $emp_id . "_fri"; $sat01 = $emp_id . "_sat"; $sunday = $_POST['$sun01']; $monday = $_POST['$mon01']; $tuesday = $_POST['$tue01']; $wednesday = $_POST['$wed01']; $thursday = $_POST['$thu01']; $friday = $_POST['$fri01']; $saturday = $_POST['$sat01']; echo $temp_name . "Sun = " . $sunday . " | " . "Mon = " . $monday . " | " ."Tue = " . $tuesday . " | " ."Wed = " . $wednesday. " | " ."Thu = " . $thursday . " | " ."Fri = " . $friday . " | " ."Sat = " . $saturday . "<br>"; $i++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/200462-help-me-with-a-scheduling-app/#findComment-1052021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.