Display values meant for two different tables on one table

Viewed 32

I didn't know how to title this but will be glad if you can help me.

I have a student examination score sheet table where about six subjects with the same grading systems are recorded on the top part of the table, while four other subjects with similar grading systems (different from the ones above) are displayed on the bottom part of the table.

I can get all the subjects and their scores to display on the table as a whole but I can't seem to be able to demarcate the subjects to fall on their part of the table.

Here is the table

student score sheet

This is my code. It seems messy but that's how much I can go: I will just paste the bottom part of the table to avoid a lengthy code.

 <tr>
   <th style="font-size:15px;color: black;text-align: center;border: 1px solid black;"></th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center;">30</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">10</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">60</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">100</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">15</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center;">30</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">10</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">60</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">100</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">15</th>

   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center;">15</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">15</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">70</th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center">100</th>

   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;"></th>
   <th width="" align="center" style="font-size:15px;color: black;background-color: dodgerblue;border: 1px solid black;text-align: center"></th>
 </tr>
 <tbody>
   <?php
                      if (!empty($exam_value->exam_result['result'])) {
                     $count = count($exam_value->exam_result['result']);
                     $comment = "";
                       $total_exams = 1;
                        foreach ($exam_value->exam_result['result'] as $exam_result_key => $exam_result_value) {
                            $exam_grand_total = $exam_grand_total + $exam_result_value->max_marks;
                            $exam_get_total   = $exam_get_total + $exam_result_value->get_marks + $exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3 + $exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6 + $exam_result_value->get_ca7 + $exam_result_value->get_ca8 + $exam_result_value->get_ca9 + $exam_result_value->get_exam;
                            // $exam_ca_total = $exam_result_value->get_marks + $exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3 + $exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6;
                            $exam_sub_total = $exam_result_value->get_marks + $exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3 + $exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6 + $exam_result_value->get_exam;
                            $test1ratio = round(($exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3) / 100 * 15);

                            $test2ratio = round(($exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6)/ 100 * 15);

                            $prytermtotal = $test1ratio + $test2ratio + $exam_result_value->get_exam;
                            // $percentage_grade = ($exam_result_value->get_marks + $exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3 + $exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6 + $exam_result_value->get_exam * 100) / $exam_result_value->max_marks;
                            if ($exam_result_value->get_marks + $exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3 + $exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6 + $exam_result_value->get_exam < $exam_result_value->min_marks) {
                                $exam_pass_status = 0;
                            }


 ?>
   <?php
  if(in_array($exam_result_value->subject_id, [11,10,23,15]))
{
if (!empty($exam_value->exam_result['result']))
{


}
else
{

}
}
?>

   <td style="border: 1px solid black;font-size:14px;width:120px;white-space: nowrap; color:black;font-weight: bold;text-align: center"><?php echo ($exam_result_value->name);?></td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca1;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?></td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca2;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca3;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca1 + $exam_result_value->get_ca2 + $exam_result_value->get_ca3;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $test1ratio;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca4;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca5;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca6;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_ca4 + $exam_result_value->get_ca5 + $exam_result_value->get_ca6;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $test2ratio;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $test1ratio;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $test2ratio;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo $exam_result_value->get_exam;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td <?php echo $style;?>><?php echo $prytermtotal;

                                if ($exam_result_value->attendence == "absent") {
                                    $exam_absent_status = 1;
                                    echo "&nbsp;" . $this->lang->line('abs');
                                }
                                ?>
   </td>
   <td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"><?php echo findExamGrade1($exam_grade, $exam_value->exam_type, $prytermtotal); ?></td>
   <td style="border: 1px solid black;font-size:15px;font-weight:bold;width:40px;text-align:left;color:black;white-space: nowrap;"><?php echo findExamGradeRemark1($exam_grade, $exam_value->exam_type, $prytermtotal); ?></td>


 </tbody>
 <?php
}
}?>

I want some specific subjects which are known as the core subjects to fall in the bottom part of the table. So, I tried to use in_array($exam_result_value->subject_id, [11,10]) but got stuck (don't even know if that would even work).

Then I did an if ($exam_result_value->subject_id = 10 || $exam_result_value->subject_id = 11) that turned up a blank bottom part of the table.

I really don't know how to go from here.

The subjects from the top part of the table keep entering the bottom part and I don't know how to stop it and display its own specific subjects and scores.

This is my array:

[exam_result] => Array
(
[exam_connection] => 0
[result] => Array
(
[0] => stdClass Object
(
[id] => 26
[exam_group_class_batch_exams_id] => 5
[subject_id] => 11
[date_from] => 2022-07-08
[time_from] => 18:13:19
[duration] => 0
[room_no] =>
[max_marks] => 1.00
[min_marks] => 1.00
[credit_hours] => 0.00
[date_to] =>
[is_active] => 0
[created_at] => 2022-07-08 17:13:35
[updated_at] =>
[exam_group_exam_results_id] => 6
[attendence] => present
[get_marks] =>
[get_ca1] => 0
[get_ca2] => 0
[get_ca3] => 0
[get_ca4] => 0
[get_ca5] => 0
[get_ca6] => 0
[get_ca7] => 0
[get_ca8] => 0
[get_ca9] =>
[get_exam] => 0
[get_tot_score] => 0
[note] =>
[rem1] =>
[name] => MATHEMATICS
[code] =>


0 Answers
Related