I am trying to display student's grades, prelim, midterm and finals.
The problem is the grade os being doubled with separate grade period grades.
This image shows the problem:
Expected Output: Is there a way to join the grades together like this image?
View:
<?php foreach($grades as $grade): ?>
<tr>
<th scope="row"><?php echo $grade['subCode']; ?></th>
<td><?php echo $grade['subject']; ?></td>
<?php if($grade['gradePeriod']=="Prelim"): ?>
<td><?php echo $grade['grade']; ?></td>
<?php else: ?>
<td>0</td>
<?php endif; ?>
<?php if($grade['gradePeriod']=="Midterm"): ?>
<td><?php echo $grade['grade']; ?></td>
<?php else: ?>
<td>0</td>
<?php endif; ?>
<?php if($grade['gradePeriod']=="Finals"): ?>
<td><?php echo $grade['grade']; ?></td>
<?php else: ?>
<td>0</td>
<?php endif; ?>
<td><?php echo $grade['remarks']; ?></td>
</tr>
<?php endforeach; ?>
Model:
public function gradePeriod(){
$this->db->select('subCode,subject,grade,gradePeriod,remarks');
$this->db->from('tbl_college_grades');
$this->db->where('studentID', ' 200171419');
$this->db->where('schoolYear','2022-2023');
$this->db->where('semester','First Semester');
$query = $this->db->get();
return $query->result_array();
}