I have multiple submit buttons in a form in admin.php file. For each action that the admin does, I have a submit button in admin.php file. One of the actions of an admin (Daily Attendance), is to mark the attendance of employees as present or absent.
When I click on the submit button for "Daily Attendance" , 3 dropdown selections appears which allows the admin to choose the year,month and date to mark the attendance. Along with this, a table is displayed with all the records from the employee table . For each record that is displayed , I am dynamically generating a radio button for attendance (values : present and absent) and a submit button (name = mark) . The admin simply marks any one of the employees as present/absent with the help of radio button , and clicks on the adjoining submit button(mark) to insert this record in the attendance table.
The selections (year,month , date ) and the radio buttons for each record are a part of a dynamically generated form . In this form I have given the ACTION attribute as "mark-attendance.php" and method = POST.
Now , I want to pass the selected value for year,month and date ; the attendance value for present or absent ,and the employee id for the employee whose record the attendance is being marked, to the page "mark-attendance.php" through POST method .
I am able to retrieve the values for year,month,date (selection) and attendance value(present/absent) . But I am unable to pass the value of employee id of the person to "mark-attendance.php" , since it is not a form input .
How do pass this value ? I want to use this value to insert a record in attendance table for that particular employee id .
Any help will be appreciated :
Here is my code : I have edited my code for space constraints
switch ($_POST['admin']) {
// if admin=>Daily Attendance
case 'Daily Attendance':
$sql_sel_emp = "select * from employee";
$res_emp = mysqli_query($conn,$sql_sel_emp);
$aff_sel = mysqli_affected_rows($conn);
//display a calendar and table with records only if records exist
if ($aff_sel>0) {
echo "<form action='test-message.php' method='POST'>
<table>
<br><br>
<tr>
<td>
<select name='year'>
<option value='2016'>2016</option>
<option value='2017'>2017</option>
</select>
</td>
<td>
<select name='month'>
<option value='01'>January</option>
<option value='02'>February</option>
</select>
</td>
<td>
<select name='day'>
<option value='01'>1</option>
<option value='02'>2</option>
</select>
</td>
</tr>
</table><br><br>";
echo "<table border='1' cellpadding='1' cellspacing='1'>
<tr>
<th>Employee Image</th>
<th>Employee Id</th>
<th>Employee Name</th>
<th>Employee Email</th>
<th>Employee DOB</th>
<th>Employee Designation</th>
<th>Employee Department</th>
<th>Attendance Status</th>
<th>Action</th>
</tr>";
while ($row=mysqli_fetch_assoc($res_emp)) {
echo "<tr>
<td>";?><img src="images/<?php echo $row['emp_image'];
?>" height="100" width="100" ><?php echo "</td>
<td>".$row['emp_id']."</td>
<td>".$row['emp_name']."</td>
<td>".$row['emp_email']."</td>
<td>".$row['emp_dob']."</td>
<td>".$row['emp_designation']."</td>
<td>".$row['emp_department']."</td>
<td><input type='radio' name='attendance'
value='present'>Present<br>
<input type='radio' name='attendance' value='absent'>Absent<br></td>
<td>
<input type='submit' name='mark' value='Mark Attendance'>
</td>
</tr>";
}
echo "</table></form>";
//display message if there are no records in temporary_employee table
} else {
$msg="No records found";
}
break;