<?php
 session_start();
 include "header.php";
 include "sidebar.php";
  if(!isset($_SESSION["userrpp"]))
  {
	header("Location: login.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">Mata 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 Mata Pelajaran</h5>
               <a href="impormapel.php"><button type="button" class="btn btn-primary rounded-pill" onclick="">Impor Data Mata 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 Mata Pelajaran berhasil di update.</font></p>";
						echo "<br> ";
				}	
				?>
              <!-- Table with stripped rows -->
              <table class="table datatable">
                <thead>
                  <tr>
                    <th scope="col">ID Mapel</th>
                    <th scope="col">Kode Mapel</th>
                    <th scope="col">Nama</th>
                    <th scope="col">Aksi</th>
                  </tr>
                </thead>
                <tbody>
				<?php
				include 'config.php';
				$result = mysqli_query($mysqli, "SELECT * from mapel ORDER BY Idmapel 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['Idmapel']."</td>";
					echo "<td>".$res['kode']."</td>";
					echo "<td>".$res['nama']."</td>";
					echo "<td><a href=\"editmapel.php?id=$res[Idmapel]\"><button type=\"button\" class=\"btn btn-info rounded-pill\">&nbsp;&nbsp;Edit&nbsp;&nbsp;</button> <a href=\"hmapel.php?id=$res[Idmapel]\" 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";
?>
 