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 –