<div class="row mb-3">
    <div class="col-lg-12">
        <h3 class="page-header"><strong>Data Mata Pelajaran</strong></h3>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        
        <div style="margin-bottom: 20px;">
            <a href="media.php?module=input_mapel" class="btn btn-success">
                <i class="fa fa-plus"></i> Tambah Mata Pelajaran
            </a>
        </div>

        <div class="panel panel-primary">
            <div class="panel-heading">
                Daftar Mata Pelajaran
            </div>

            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th class="text-center" width="50px">No</th>
                                <th class="text-center">Nama Mata Pelajaran</th>
                                <th class="text-center" width="200px">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
<?php
$no = 1;
// Mengambil data mata pelajaran
$sql = mysqli_query($koneksi, "SELECT * FROM mata_pelajaran ORDER BY nama_mp ASC");

while ($rs = mysqli_fetch_array($sql)) {
?>
                            <tr>
                                <td class="text-center"><?php echo $no++; ?></td>
                                <td><?php echo htmlspecialchars($rs['nama_mp']); ?></td>
                                <td class="text-center">
                                    
                                    <a href="media.php?module=input_mapel&act=edit&idm=<?php echo $rs['idm']; ?>" class="btn btn-info btn-sm">
                                        <i class="fa fa-edit"></i> Edit
                                    </a>
                                    
                                    <a href="./module/simpan.php?act=hapus_mapel&idm=<?php echo $rs['idm']; ?>" 
                                       onclick="return confirm('Yakin ingin menghapus mata pelajaran <?php echo $rs['nama_mp']; ?>?')" 
                                       class="btn btn-danger btn-sm">
                                        <i class="fa fa-trash"></i> Hapus
                                    </a>

                                </td>
                            </tr>
<?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>