Jump to content

Help me with a scheduling app!


ChrisF79

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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++;
}
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.