我正在为我的论文创建一个系统供学校使用。有一个方面我无法工作。我希望能够同时为多个人设置出勤率。这里有一张图片可以向您展示表单的外观:
所有值都设置为present ,因此如果需要,只能将一对夫妇更改为缺席。按下表单底部的按钮后,我希望它导航到确认页面。我使用 MySQl 查询来获取尚未设置出勤的员工列表,并使用包含标签将其放置在 HTML 表单中。我必须生成列表的代码如下:
<?php
// Get a list of all items and display them in ID order
$dynamicList = "";
$sql = mysql_query("SELECT StaffID, StaffName FROM StaffDetails WHERE StaffID NOT IN (SELECT StaffID FROM StaffAttendance WHERE AttendanceDate = curdate()) ORDER BY StaffID ASC");
// Show list
$productCount = mysql_num_rows($sql);
$setTodaysAttendanceList = "";
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)) {
$StaffID = $row["StaffID"];
$StaffName = $row["StaffName"];
$setTodaysAttendanceList .= '<tr style="font-size:15px;">
<td><a href="../staff_member_details.php?id=' . $StaffID . '">' . $StaffID . '</a></td>
<td><a href="../staff_member_details.php?id=' . $StaffID . '">' . $StaffName . '</a></td>
<td><label>
<select name="attendance_status" id="attendance_status">
<option value="Present">Present</option>
<option value="Absent">Absent</option>
</select>
</label></td>
<td><label>
<textarea cols="21" rows="5" name="notes" id="notes" placeholder="Enter notes here..."></textarea>
</label></td>
</tr>';
}
} else {
$setTodaysAttendanceList = "There are no records listed at this time";
}
mysql_close();
?>
然后在 HTML 中我有这个:
<form action="set_multiple_staff_attendance_confirm.php" enctype="multipart/form-data" name="StaffAttendanceForm" id="StaffAttendanceForm" method="post">
<?php echo $setTodaysAttendanceList; ?>
<tr style="font-size:15px;">
<td></td>
<td></td>
<td></td>
<td><label>
<input type="submit" name="addNewRow" id="addNewRow" value="Add Staff Attendance Records" />
</label></form></td>
</tr>
当它重定向到下一页时,我有一个如下所示的插入查询:
<?php
// Add row to database
if (isset($_POST['staff_id'])) {
$staff_id = mysql_real_escape_string($_POST['staff_id']);
$attendance_status = mysql_real_escape_string($_POST['attendance_status']);
$notes = mysql_real_escape_string($_POST['notes']);
$sql .= mysql_query("INSERT INTO StaffAttendance (StaffID, AttendanceDate, AttendanceStatus, Notes) VALUES
('$staff_id', now(), '$attendance_status', '$notes')") or die (mysql_error());
$editid = mysql_insert_id();
}
?>
我知道这是一个漫长而复杂的询问方式,但我只是表明我已经尝试过并且完全被卡住了!