<?php include 'includes/header.php'; ?>
<?php include 'includes/sidebar.php' ?>

<?php include 'includes/topbar.php'; ?>

<!-- page content -->
<div class="right_col" role="main">
  <div class="">

    <div class="clearfix"></div>

    <div class="row">
      <div class="col-md-12 col-sm-12 ">
        <div class="x_panel">
          <div class="x_title">
            <h2>Registered Students</h2>
            <ul class="nav navbar-right panel_toolbox">
              <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
              </li>
            </ul>
            <div class="clearfix"></div>
          </div>
          <div class="x_content">
            <div class="row">
              <div class="col-sm-12">
                <div class="card-box table-responsive">
                  <style type="text/css">
                    .table-bordered {
                      border: 1px solid grey;
                    }

                    table {
                      border-collapse: collapse;
                    }
                  </style>
                  <table id="datatable-buttons" class="table table-striped table-bordered" style="width:100%">
                    <thead>
                      <tr>
                        <th>Full Name</th>
                        <th>Gender</th>
                        <th>Class</th>
                        <th>Live Place</th>
                        <th>Status</th>
                        <th>Amount</th>
                        <th>Update</th>
                        <th>Delete</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      include 'connection.php';
                      $select = "SELECT * FROM students WHERE cl= 'STD I' AND  class_status='active'";
                      $sql = mysqli_query($conn, $select);
                      $k = 1;
                      $total = 0;
                      while ($fetch = mysqli_fetch_object($sql)) {
                        $f = $fetch->ud;
                        $e = $fetch->jan;
                        $d = $fetch->apr;
                        $c = $fetch->jul;
                        $b = $fetch->sep;
                        $a = $fetch->others;
                        $g = $fetch->sta;
                        $h = $fetch->tour;
                        $amount = $a + $b + $c + $d + $e + $f +$g+$h;

                      ?>
                        <tr>
                          <td><?php echo $fetch->fn; ?></td>
                          <td><?php echo $fetch->gd; ?></td>
                          <td><?php echo $fetch->cl; ?></td>
                          <td><?php echo $fetch->lp; ?></td>
                          <td><?php echo $fetch->st; ?></td>
                          <td><?php echo number_format($amount) . " /="; ?></td>
                          <td style="width: 5%;"><a href="std1_update_students.php?key=<?php echo $fetch->id;  ?>"><i style="color: red; font-size: 18px; margin-left: 20px; " class="fa fa-edit"></i></a></td>
                          <td style="width: 5%;"><a href="delete_students.php?key=<?php echo $fetch->id;  ?>"><i style="color: red; font-size: 18px; margin-left: 20px; " class="fa fa-trash"></i></a></td>
                        </tr>
                      <?php

                        $total += $amount;
                        $k++;
                      }
                      ?>
                    </tbody>
                  </table>
                  <table>
                    <tr>
                      <td>Total Amount : <button class=" btn btn-info"><b><?php echo number_format($total) . " /="; ?></b></button></td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>


      <!-- /page content -->

      <?php include 'includes/footer.php'; ?>