Php 如何在AttendanACE_status==1的foreach循环中计算当前总出席人数
如果Php 如何在AttendanACE_status==1的foreach循环中计算当前总出席人数,php,mysql,codeigniter,Php,Mysql,Codeigniter,如果attendenace\u status==1,我如何计算每个循环的总出席人数 <table id="" class="table table-bordered std_table"> <thead> <tr> <th style="width:100%" class="col-sm-3">Name</th> <?php f
attendenace\u status==1,我如何计算每个循环的总出席人数
<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):
$ctr = $ctr + $emp_attendance->attendance_status; ?>
<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">H</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>
<?php endforeach; ?>
<?php endforeach; ?>
<td><?php
$ctr=0;
if ($emp_attendance->attendance_status == 1) {
$ctr++;
echo $ctr;
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
是1。Attendance Attendancese不,这里有打字错误,代码中没有
echo $ctr;