<?php
 session_start();
 include "header.php";
 include "sidebar.php";
 
?>

  
  <main id="main" class="main">

    <div class="pagetitle">
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="index.php">Home</a></li>
          <li class="breadcrumb-item">Data</li>
          <li class="breadcrumb-item active">Tahun Pelajaran</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section">
      <div class="row">
        <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              <h5 class="card-title">Data Tahun Pelajaran</h5>
               <a href="importapel.php"><button type="button" class="btn btn-primary rounded-pill" onclick="">Impor Data Tahun Pelajaran</button></a>
			   <?php 
				if(isset($_GET['berhasil'])){
					echo "<p>".$_GET['berhasil']." Data berhasil di import.</p>";
				}
				
				if (isset($_GET['ed'])) {
					echo "<p><font color='green'>Data Tahun Pelajaran berhasil di update.</font></p>";
						echo "<br> ";
				}	
				?>
              <!-- Table with stripped rows -->
              <table class="table datatable">
                <thead>
                  <tr>
                    <th scope="col">Kode Tapel</th>
                    <th scope="col">Tahun Pelajaran</th>
                    <th scope="col">Semester</th>
                    <th scope="col">Aksi</th>
                  </tr>
                </thead>
                <tbody>
				<?php
				include 'config.php';
				$result = mysqli_query($mysqli, "SELECT * from tapel ORDER BY Idtapel ASC");
				$counter=0;
				// Fetch the next row of a result set as an associative array
				while ($res = mysqli_fetch_assoc($result)) {
					$counter=$counter+1;
					?>
					<tr>
                    <?php
					echo "<td>".$res['Idtapel']."</td>";
					echo "<td>".$res['nama']."</td>";
					echo "<td>".$res['semester']."</td>";
					echo "<td><a href=\"edittapel.php?id=$res[Idtapel]\"><button type=\"button\" class=\"btn btn-info rounded-pill\">&nbsp;&nbsp;Edit&nbsp;&nbsp;</button> <a href=\"htapel.php?id=$res[Idtapel]\" onclick=\"return confirm('Yakin ingin menghapus data ini?');\"><button type=\"button\" class=\"btn btn-danger rounded-pill\">Hapus</button></a></td></tr>";
					
					
				 
				}
						?>
                                  
                </tbody>
              </table>
              <!-- End Table with stripped rows -->

            </div>
          </div>

        </div>
      </div>
    </section>

  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
  <?php
 include "footer.php";
?>
 