【发布时间】:2017-05-30 05:14:20
【问题描述】:
我如何计算 attendnace_status == 1 为 Present 的每个循环的总出席人数
<table id="" class="table table-bordered std_table">
<thead>
<tr>
<th style="width:100%" class="col-sm-3">Name</th>
<?php foreach ($dateSl as $edate) : ?>
<th class="std_p"><?php echo $edate ?></th>
<?php endforeach; ?>
<th width="100%" style="width:100%" class="col-sm-3">Present</th>
</tr>
</thead>
<tbody>
<?php foreach ($attendance as $key => $v_employee): ?>
<tr>
<td style="width: 100%" class="col-sm-3"><?php echo $employee[$key]->first_name . ' ' . $employee[$key]->last_name . ' ' . $employee[$key]->employment_id ?></td>
<?php foreach ($v_employee as $v_result): ?>
<?php foreach ($v_result as $emp_attendance): ?>
<td>
<?php
if ($emp_attendance->attendance_status == 1) {
echo '<span style="padding:2px; 4px" class="label label-success std_p">P</span>';
}if ($emp_attendance->attendance_status == 2) {
echo '<span style="padding:2px; 4px" class="label label-success std_p">HD</span>';
}if ($emp_attendance->attendance_status == '3') {
echo '<span style="padding:2px; 4px" class="label label-danger std_p">L</span>';
}if ($emp_attendance->attendance_status == '0') {
echo '<span style="padding:2px; 4px" class="label label-danger std_p">A</span>';
}if ($emp_attendance->attendance_status == 'H') {
echo '<span style="padding:2px; 4px" class="label label-info std_p">H</span>';
}
?>
</td>
<td>
<?php endforeach; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
我如何计算 attendnace_status == 1 为出席的 foreach 循环中出席的总出席人数
在<th>Present</p> 下,我想计算每个员工在 foreach 循环中的总 P 出勤率。如果员工 P 状态 25 天,则当前计数 25
【问题讨论】:
-
为attendnace_status==1声明一个value=0的变量,当attendnace_status == 1时增加1
标签: php mysql codeigniter