<main class="common_margin" id="main">
    <div class="main-inner-content main-wrap">
      <?php if (isset($student_results) && !empty($student_results)) { 
          $total_mark = 0;$total_scored_mark=0; ?>

          <div class="stud-drade-wraps mb-5">  
            <div class="breadcrumb-section">
              <ol class="breadcrumb breadcrumb-back"> 
                <a href="<?= base_url(); ?>student/my-grades"> <li class="breadcrumb-item"> Back</li>  </a>
              </ol> 
            </div>
            <p>My grades / <?php echo $student_results[0]['e_name'] .'   '. $student_results[0]['bs_date'] ?></p>
        </div> 
        <div class="stud-table-wrap">
            <h6><?php 
            echo $student_results[0]['e_name'] .'   '. $student_results[0]['bs_date'] ?>
            </h6>
          <?php  foreach ($student_results as $key => $value) { 
              $total_mark = $total_mark+$value['total_marks'];
              $total_scored_mark =  $total_scored_mark+$value['get_marks']; 
          ?>
        
        <?php }  ?>
            <table>
                <thead>
                <tr id="heading-height">
                  <th>Subject</th>
                  <th>Total Marks</th>
                  <th>Passing marks</th>
                  <th>Scored</th>
                  <th>Grade</th>
                  <th></th>
                </tr>
            </thead>
      <?php foreach ($student_results as $key => $value) { ?>
                <tr>
                  <td><?php echo $value['subject_name']; ?></td>
                  <td><?php echo $value['total_marks']; ?></td>
                  <td><?php echo $value['passing_marks']; ?></td>
                  <td><?php echo $value['get_marks']; ?></td>
                  <td><?php echo $value['grade_name']; ?></td>
                </tr>
      <?php } ?>     
                  <tr class="total-bold">
                    <td>Grand Total</td>
                    <td><?php echo $total_mark; ?></td>
                    <td></td>
                    <td><?php echo $total_scored_mark; ?></td>
                    <?php 
                    if ($total_scored_mark == 0) {
                      $scored_percentage = 0;
                    }else{
                      $scored_percentage = round((($total_scored_mark*100)/$total_mark), 2);} 
                    $grade = student_grade_show($scored_percentage);
                    ?>
                    <td><?php echo $grade['grade_name'] ?></td>
                  </tr>
                </table>
      <?php  } ?>
        </div>
    </div>
</main>