How to combine PHP and Vue to realize the late and early departure statistics function of employee attendance
In modern enterprise management, attendance management is a very important task. In order to efficiently count employee attendance, we can use PHP and Vue to implement the late arrival and early departure statistics function. The following will introduce how to use these two tools to build a simple attendance management system and provide specific code examples.
You can add it to the table according to actual needs Other fields, such as employee name, department, etc.
$servername = "localhost";
$username = "your_username";
$password = "your_password ";
$dbname = "your_database";
// Create a database connection
$conn = new mysqli($servername, $username, $password, $dbname);
if ( $conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Query attendance records
$sql = "SELECT * FROM attendance";
$result = $conn-> ;query($sql);
// Process query results
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) { // 处理每一条记录 }
} else {
echo "0 results";
}
//Close the database connection
$conn->close();
?>
<table>
<thead>
<tr>
<th>员工姓名</th>
<th>考勤日期</th>
<th>上班时间</th>
<th>下班时间</th>
</tr>
</thead>
<tbody>
<tr v-for="record in attendanceData">
<td>{{ record.employeeName }}</td>
<td>{{ record.date }}</td>
<td>{{ record.inTime }}</td>
<td>{{ record.outTime }}</td>
</tr>
</tbody>
</table>