显示学生的每月出勤报告

编程入门 行业动态 更新时间:2024-10-10 13:19:00
本文介绍了显示学生的每月出勤报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为什么不向我显示谁在场和谁不在?

文件位于此处.

该表的出勤人数为列:

attendance_id |时间戳|年|class_id |section_id |学生卡|class_routine_id |状态

attendance_id | timestamp | year | class_id | section_id | student_id | class_routine_id | status

状态值:(0个未定义,1个存在,2个不存在)

Status values: (0 undefined, 1 present, 2 absent)

<?php $data = array(); $students = $this->db->get_where('enroll', array('class_id' => $class_id, 'year' => $running_year, 'section_id' => $section_id))->result_array(); foreach ($students as $row): ?> <tr> <td style="text-align: center;"> <?php echo $this->db->get_where('student', array('student_id' => $row['student_id']))->row()->name; ?> </td> <?php $status = 0; for ($i = 1; $i <= $days; $i++) { $timestamp = strtotime($i . '-' . $month . '-' . $year[0]); $this->db->group_by('timestamp'); $attendance = $this->db->get_where('attendance', array('section_id' => $section_id, 'class_id' => $class_id, 'year' => $running_year, 'timestamp' => $timestamp, 'student_id' => $row['student_id']))->result_array(); foreach ($attendance as $row1): $month_dummy = date('d', $row1['timestamp']); if ($i == $month_dummy) $status = $row1['status']; endforeach; ?> <td style="text-align: center;"> <?php if ($status ==1 ) { ?> <i class="entypo-record" style="color: #00a651;"></i> <?php } if($status == 2) { ?> <i class="entypo-record" style="color: #ee4749;"></i> <?php } $status =0;?> </td>

推荐答案

我认为我发现了您的问题.您错过了每个周期的结尾和其他几个括号.我不知道我是否可以将您的代码很好地组合在一起,但是至少现在应该写得更好.香港专业教育学院在这里把两个相同的代码与不同的语法",您可以看一下看起来更好.

I think I found your problem. You missed the end of a for each cycle and few other brackets. I dont know if I put your code together in a good way but at least it should be written better now. Ive put two same codes here with "different syntax" you can take a look which looks better.

<?php $data = array(); $students = $this->db->get_where('enroll', array('class_id' => $class_id, 'year' => $running_year, 'section_id' => $section_id))->result_array(); foreach ($students as $row): ?> <tr> <td style="text-align: center;"> <?php echo $this->db->get_where('student', array('student_id' => $row['student_id']))->row()->name; ?> </td> <?php $status = 0; for ($i = 1; $i <= $days; $i++) { $timestamp = strtotime($i . '-' . $month . '-' . $year[0]); $this->db->group_by('timestamp'); $attendance = $this->db->get_where('attendance', array('section_id' => $section_id, 'class_id' => $class_id, 'year' => $running_year, 'timestamp' => $timestamp, 'student_id' => $row['student_id']))->result_array(); } foreach ($attendance as $row1): $month_dummy = date('d', $row1['timestamp']); if ($i == $month_dummy) { $status = $row1['status']; } endforeach; endforeach; ?> <td style="text-align: center;"> <?php if ($status == 1) { ?> <i class="entypo-record" style="color: #00a651;"></i> <?php } if ($status == 2) { ?> <i class="entypo-record" style="color: #ee4749;"></i> <?php } $status = 0; ?> </td>

我也建议您使用这种语法(我认为最好先回显html标签,然后再使用?php十次,但这是每个人的选择):

And also i suggest you using this syntax (i think its better to echo the html tags then using ?php ten times but its everyones choice):

<?php $data = array(); $students = $this->db->get_where('enroll', array('class_id' => $class_id, 'year' => $running_year, 'section_id' => $section_id))->result_array(); foreach ($students as $row): echo '<tr> <td style="text-align: center;">' . $this->db->get_where('student', array('student_id' => $row['student_id']))->row()->name . '</td>'; $status = 0; for ($i = 1; $i <= $days; $i++) { $timestamp = strtotime($i . '-' . $month . '-' . $year[0]); $this->db->group_by('timestamp'); $attendance = $this->db->get_where('attendance', array('section_id' => $section_id, 'class_id' => $class_id, 'year' => $running_year, 'timestamp' => $timestamp, 'student_id' => $row['student_id']))->result_array(); } foreach ($attendance as $row1): $month_dummy = date('d', $row1['timestamp']); if ($i == $month_dummy) { $status = $row1['status']; } endforeach; endforeach; echo '<td style="text-align: center;">'; if ($status === 1) { echo '<i class="entypo-record" style="color: #00a651;"></i>'; } else if ($status == 2) { echo '<i class="entypo-record" style="color: #ee4749;"></i>'; } $status = 0; echo '</td>';

更多推荐

显示学生的每月出勤报告

本文发布于:2023-10-27 04:23:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532302.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报告   学生

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!