<?php
$sql = "SELECT *, employees.employee_id AS empid,
attendance.id AS attid FROM attendance LEFT JOIN employees
ON employees.id=attendance.employee_id
ORDER BY attendance.date DESC, attendance.time_in DESC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$status = ($row['status'])?'<span class="label label-warning pull-right">ontime</span>':'<span class="label label-danger pull-right">late</span>';
echo "
<tr>
<td class='hidden'></td>
<td>".date('M d, Y', strtotime($row['date']))."</td>
<td>".$row['empid']."</td>
<td>".$row['firstname'].' '.$row['lastname']."</td>
<td>".date('h:i A', strtotime($row['time_in'])).$status."</td>
<td>".date('h:i A', strtotime($row['time_out']))."</td>
<td>
<button class='btn btn-success btn-sm btn-flat edit' data-id='".$row['attid']."'><i class='fa fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm btn-flat delete' data-id='".$row['attid']."'><i class='fa fa-trash'></i> Delete</button>
</td>
</tr>
";
}
?>