Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

How to name my textboxes

$
0
0

Hello guys, I would like to make a form for employees' attendance from a start_date to an end_date. The name of the employees are listed from top to bottom and the dates will be listed from left to right of the names of the employees. My problem is that I don't know how to name my textboxes so the system would know that a particular textbox is for employee 'A' and for a particular date between the start_date and end_date. The expected datatype to be entered into the textboxes is an integer or decimal number like 1 or 0.5.

 

Here is what I've done so far:

$sql = "SELECT DATE_FORMAT(sp_start, '%b %e, %Y'), DATE_FORMAT(sp_end, '%b %e, %Y'),
			TO_DAYS(sp_start), TO_DAYS(sp_end)
		FROM salary_periods 
		WHERE sp_id = '$sp_id'";
$sres = mysql_query($sql); $srow = mysql_fetch_array($sres); 
?>
<form action="somepage.php" method="post">
<table>
	<tr><td colspan="4" align="center">Salary Period</td></tr>
	<tr class="even">
		<td width="100" align="right">Start Date</td>
		<td width="250" align="left"><?PHP echo $srow[0] ?></td>
		<td width="100" align="right">End Date</td>
		<td width="250" align="left"><?PHP echo $srow[1] ?></td>
	</tr>
</table><br />
<table>
	<tr>
		<td width="150" align="center">Employee</td>
		<td width="550" align="center" colspan="<?PHP echo $srow[3] - $srow[2] + 1; ?>">Dates</td>
	</tr>
	<tr>
		<td> </td>
		<?PHP 
		for ($j=$srow[2]; $j<=$srow[3]; $j++) {
			$sql = "SELECT DATE_FORMAT(FROM_DAYS($j), '%m/%d')";
			$tres = mysql_query($sql); $trow = mysql_fetch_array($tres); 
			?><td align="center"><?PHP echo $trow[0] ?></td><?PHP
		}
		?>
	</tr>
	<?PHP
	$i = 1; 
	$sql = "SELECT emp_id, CONCAT(lname,', ',fname) 
			FROM employees WHERE active = 1";
	$res = mysql_query($sql); 
	while ($row = mysql_fetch_array($res)) {
		$m = fmod($i, 2);
		if ($m == 0) { // $i is EVEN
			?><tr class="even"><?PHP
		} else { // $i is ODD
			?><tr class="odd"><?PHP
		}
		?>
			<input type="hidden" name="emp_id<?PHP $i ?>" value="<?PHP echo $row[0] ?>">
			<td align="left"><?PHP echo $row[1] ?></td>
			<?PHP 
			for ($j=$srow[2]; $j<=$srow[3]; $j++) {
				$sql = "SELECT DATE_FORMAT(FROM_DAYS($j), '%m/%d')";
				$tres = mysql_query($sql); $trow = mysql_fetch_array($tres); 
				?><td><input type="text" name="TextboxNameHere" size="2" style="text-align:right;"></td><?PHP
			}
			?>
			
		</tr>
		<?PHP
		$i++;
	}
	?>
</table>
</form>
<?PHP

How should I name my textboxes so that each textbox will be assigned to a particular employee and a particular date?


Viewing all articles
Browse latest Browse all 13200

Trending Articles