0
도시 내 결과 중첩 루프 반복 값
MY 제어기
if((int)$id) {
$studentID = [];
$comments = [];
$this->data['set'] = $id;
$schoolyearID = $this->session->userdata('defaultschoolyearID');
$this->data['classes'] = $this->student_m->get_classes();
$this->data['students'] = $this->student_m->get_order_by_student(array('classesID' => $id, 'schoolyearID' => $schoolyearID));
foreach($this->data['students'] as $key => $val){
$studentID[] = $val->studentID;
}
foreach ($studentID as $student) {
$comments[] = $this->sattendance_m->get_comment($id,$student);
}
$this->data['comments'] = $comments;
$this->load->view('_layout_main', $this->data);
MY 모달
원함 (210)내 VIEW
<?php foreach($students as $student) { ?>
<tr>
<td data-title="<?=$this->lang->line('attendance_name')?>">
<?php echo $student->name; ?>
</td>
<td data-title="<?=$this->lang->line('attendance_roll')?>">
<?php echo $student->roll; ?>
</td>
<td data-title="<?=$this->lang->line('attendance_comment')?>">
<?php
if(count($comments))
{
$attendanceID = [];
$student_ID = [];
$comment = [];
$classid = [];
foreach ($comments as $key => $row) {
foreach ($row as $value) {
$attendanceID [] = $value->attendanceID;
$student_ID [] = $value->studentID;
$classid [] = $value->classesID;
//$comments [] = $value->comment;
$key = array_search($student->studentID,$student_ID); //find same StudentID ids
$key2 = array_search($set,$classid); // find same classID
if($student_ID[$key] == $student->studentID && $set == $classid[$key2]){
?>
<?php
echo $value->comment; // Showing Comment where Both IDs same
?>
<?php }
}
}
}
?>
</td>
<?php } ?>
</tr>
<?php } ?>
나는 학생증 & ClassID가와 studentID의 쇼 관련 의견 일치를 원하지만 당신은 같은 반복 모든 코멘트를 보는 등이 코드에 ,, 때문에 중첩 루프하지만 돈이 될 수 있습니다 이 문제를 해결하는 방법과 내가 잘못하고있는 부분을 알지 못합니다.
아래의 나에게 빈 ,,, 아무것도를 보여주는로 보기 변경 주석의 foreach에서 다음
: 당신의 컨트롤러
은 다음과 같습니다 루프에 대한 의견을 chnage –