1
public function admin()
{
// get the current date employee logged in details
$data['get_attendance'] = $this->attendance_model->get_attendance();
// get the active employee details
$data['get_employee'] = $this->attendance_model->get_employee();
//print_r($data['get_employee']); exit();
// attendance page
$data['header'] = "Employee";
$data['sub_header'] = "Attendance employee";
$data['main_content'] = 'attendance/admin_list';
$this->load->view('employeelayout/main',$data);
}
型号
public function get_attendance()
{
return $this->db->where('date',date('Y-m-d'))->get('attendance')->result_array();
}
public function get_employee()
{
return $this->db->where('is_active',1)->get('employee')->result_array();
}
查看
<?php $count = 1 ?>
<?php foreach ($get_employee as $employee) { ?>
<tr class="gradeX">
<td><?php echo $count++ ?></td>
<td><?php echo $employee['first_name'] . ' ' . $employee['last_name'] ?></td>
<td><?php echo $employee['employee_number'] ?></td>
<?php foreach ($get_attendance as $attendance) : ?>
<!-- if employee exists -->
<?php if($employee['employee_id'] == $attendance['employee_id']) { ?>
<td><?php echo date('M-Dj-Y',strtotime($attendance['date'])) ?></td>
<td><?php echo $attendance['mark_in_time'] ?></td>
<td>mark out going</td>
<td>Active</td>
<?php break; ?>
<?php } elseif($employee['employee_id'] != $attendance['employee_id']) { ?>
<td><?php echo "i'm absent" ?></td>
<?php break; ?>
<?php } ?>
<?php endforeach; ?>
</tr>
<?php } ?>
我婉显示嵌套的foreach t显示当前登录的(当前)员工并显示缺席员工。我从员工表中获取员工详细信息。 以及考勤表的出勤详情。如果某位员工缺席,并且我想显示缺席,则会显示登录详细信息。在这里foreach循环不能正确显示条件。循环有什么问题。
尝试过,但现在使用。 – Rakesh
仍然循环错误的 – Rakesh
什么错误来了? – ichadhr