Online Course

DNR09 - Membuat Pengaturan Data Kelompok Mapel & Sub Kelompok Mapel

Membuat Pengaturan Data Kelompok Mapel & Sub Kelompok Mapel

Pertama, Buat tabel baru dengan nama tb_kelmapel di database

Struktur dari tabel tb_kelmapel

tb-kelmapel

Kedua, Buat tabel baru dengan nama tb_subkelmapel di database

Struktur dari tabel tb_subkelmapel

tb-subkelmapel

Ketiga, Buat file baru dengan nama kelmapel.php simpan di folder adminweb

isi dari file kelmapel.php seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Data Kelompok Mata Pelajaran
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Data Kelompok Mapel
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="input_kelmapel.php" title="Input data"><button name="input" class="btn btn-primary"><i class="fa fa-plus-square-o fa-fw"></i> Input</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">

                            <!-- /.tabel responsive -->
                                <div class="table-responsive">
                                    <table class="table table-bordered table-hover table-striped">
                                        <thead>
                                            <tr>
                                                <th>No</th>
                                                <th>Nama Kelompok Mapel</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 10; /*batas tampilan setiap halaman*/
                                        if ( empty( $pg ) ) {
                                        $posisi = 0;
                                        $pg = 1;
                                        } else {
                                        $posisi = ( $pg - 1 ) * $batas;
                                        }
                                        /*Jika variabel $pg kosong maka akan menampilkan halaman pertama dengan batas baris 10*/

                                        $ambildata=mysqli_query($conect, "select*from tb_kelmapel order by id_kelmapel asc limit $posisi, $batas");
                                        $jumlah=mysqli_num_rows($ambildata);  /*mysql_num_rows untuk menghitung total baris di tabel databse*/
                                        if($jumlah == 0){  //jika tidak ada data
                                            ?>
                                        <tr>
                                            <td colspan="6">Tidak Terdapat Data</td>
                                        </tr>
                                        <?php
                                        }else{
                                        //jika ada data di tb_brand
                                        while($a=mysqli_fetch_array($ambildata)){ /*mysql_fetch array untuk mengambil data di setiap field di tabel databse*/
                                        ?>
                                        <tr>
                                            <td><?php echo $posisi=$posisi+1;?></td>
                                            <td><?php echo $a['nama_kelmapel'];?></td>
                                            <td><a href="hapus_kelmapel.php?id_kelmapel=<?php echo $a['id_kelmapel'];?>" onclick="return confirm('Yakin akan meghapus data ini')" title="Hapus data"><button class="btn btn-danger btn-sm"><i class="fa fa-trash-o fa-fw"></i> Hapus</button></a>
                                            <a href="edit_kelmapel.php?id_kelmapel=<?php echo $a['id_kelmapel'];?>" title="Edit data"><button class="btn btn-primary btn-sm"><i class="fa fa-pencil-square-o fa-fw"></i> Edit</button> </a>
                                            </td>
                                        </tr>
                                        <?php
                                            }
                                        }
                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                                <!-- /.tabel responsive -->

                                <div class="text-center">
                                    <?php
                                //script paging, untuk menampikan setiap halaman
                                $jml_data = mysqli_num_rows(mysqli_query($conect, "select*from tb_kelmapel order by id_kelmapel asc"));
                                $JmlHalaman = ceil($jml_data/$batas); //ceil digunakan untuk pembulatan keatas
                                if($jml_data != 0){
                                if ( $pg > 1 ) {
                                $link = $pg-1;
                                $prev = "<a href='?pg=$link'><button name='prev' class='btn btn-primary btn-sm'>Prev</button></a> ";
                                } else {
                                $prev = "<button name='prev' class='btn btn-default btn-sm'>Prev </button> ";
                                }
                                $nmr = '';
                                for ( $i = 1; $i<= $JmlHalaman; $i++ ){

                                if ( $i == $pg ) {
                                $nmr .= "<button name='prev' class='btn btn-primary btn-sm'>$i</button> ";
                                } else {
                                $nmr .= "<a href='?pg=$i'><button name='prev' class='btn btn-default btn-sm'>$i</button></a> ";
                                }
                                }
                                if ( $pg < $JmlHalaman ) {
                                $link = $pg + 1;
                                $next = "<a href='?pg=$link'><button name='prev' class='btn btn-primary btn-sm'>Next</button></a> ";
                                } else {
                                $next = "<button name='prev' class='btn btn-default btn-sm'>Next</button> ";
                                }
                                echo $prev.$nmr.$next;
                                ?>
                                <br><br>
                                <span class="text-muted">Menampilkan <?php echo $jumlah; ?> dari <?php echo $jml_data; ?> Record </span>
                                <?php
                                }
                                ?>
                                </div>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasilnya akan seperti ini

Jalankan di localhost dengan memasukan alamat di url nya contoh localhost/sisfomik/adminweb/kelmapel.php

kelmapel

Keempat, Buat file baru dengan nama input_kelmapel.php simpan di folder adminweb

isi dari file input_kelmapel.php seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Tambah Data Kelompok Mapel
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Tambah Data Kelompok Mapel
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nama)){  //jika field nama kosong
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Masukan Nama </div>";
                }
                else{
                $save=mysqli_query($conect, "INSERT INTO tb_kelmapel(id_kelmapel,nama_kelmapel) VALUES ('','$nama')");
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Disimpan');document.location='kelmapel.php'</script>";
                }
                else{  //jika simpan gagal
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Error</div>";
                }

                }
                }

                if($_POST['status'] == "Aktif"){
                    $aktif='checked';
                }elseif($_POST['status'] == "Tidak Aktif"){
                    $pasif='checked';
                }
                ?>
                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="kelmapel.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">
                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <?php echo $error;?>
                            <div class="form-group row">
                            <label class="col-lg-3 control-label">Nama Kelompok Mapel</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama Kelompok" maxlength="30" value="<?php echo $_POST['nama'];?>"/>
                            </div>
                        </div>


                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasilnya akan seperti ini

input-kelmapel

Kelima, Buat file baru dengan nama edit_kelmapel.php simpan di folder adminweb

isi dari file edit_kelmapel.php seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Ubah Data Kelompok Mata Pelajaran
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Ubah Data Kelompok Mapel
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //ambil data dari tabel berdasarkan id
                $tampildata=mysqli_query($conect, "select*from tb_kelmapel where id_kelmapel='$_GET[id_kelmapel]'");
                $b=mysqli_fetch_array($tampildata);

                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nama)){  //jika field nama kosong
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Masukan Nama Semester </div>";
                }
                else{
                $save=mysqli_query($conect, "UPDATE tb_kelmapel set nama_kelmapel='$nama' where id_kelmapel='$_GET[id_kelmapel]'");
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Disimpan');document.location='kelmapel.php'</script>";
                }
                else{  //jika simpan gagal
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Error</div>";
                }

                }
                }

                ?>
                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="kelmapel.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">
                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <?php echo $error;?>
                            <div class="form-group row">
                            <label class="col-lg-3 control-label">Nama Kelompok Mapel</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" name="nama" id="nama" placeholder="Kelompok Mapel" maxlength="30" value="<?php echo $b['nama_kelmapel'];?>"/>
                            </div>
                        </div>

                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasilnya akan seperti ini

edit-kelmapel

Keenam, Buat file baru dengan nama hapus_kelmapel.php simpan di folder adminweb

isi dari file hapus_kelmapel.php seperti ini

<?php
session_start();
//panggil koneksi
include "../assets/relasi/koneksi.php";

$id=$_GET['id_kelmapel'];  //dapatkan id

if(isset($id)){ //jika ada id
//hapus data di tabel
$hapus=mysqli_query($conect, "DELETE from tb_kelmapel where id_kelmapel='$id'");
//jika hapus berhasil
if($hapus){
    echo"<script>alert('Data Berhasil di Hapus');document.location='kelmapel.php'</script>";
}
else{ //jika gagal
    echo"<script>alert('Error Bos !!');document.location='kelmapel.php'</script>";
}

}
?>

Oke, Selesai untuk DATA KELOMPOK MAPEL

Selanjutnya membuat pengaturan data sub kelompok mapel

Pertama, Buat file baru dengan nama subkelmapel.php simpan di folder adminweb

isi dari file subkelmapel.pgp seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Data Sub Kelompok Mata Pelajaran
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Data Sub Kelompok Mapel
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="input_subkelmapel.php" title="Input data"><button name="input" class="btn btn-primary"><i class="fa fa-plus-square-o fa-fw"></i> Input</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">

                            <!-- /.tabel responsive -->
                                <div class="table-responsive">
                                    <table class="table table-bordered table-hover table-striped">
                                        <thead>
                                            <tr>
                                                <th>No</th>
                                                <th>Nama Sub Kelompok Mapel</th>
                                                <th>Kelompok Mapel</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 10; /*batas tampilan setiap halaman*/
                                        if ( empty( $pg ) ) {
                                        $posisi = 0;
                                        $pg = 1;
                                        } else {
                                        $posisi = ( $pg - 1 ) * $batas;
                                        }
                                        /*Jika variabel $pg kosong maka akan menampilkan halaman pertama dengan batas baris 10*/

                                        $ambildata=mysqli_query($conect, "select*from tb_subkelmapel, tb_kelmapel where tb_subkelmapel.id_kelmapel=tb_kelmapel.id_kelmapel order by id_subkelmapel asc limit $posisi, $batas");
                                        $jumlah=mysqli_num_rows($ambildata);  /*mysql_num_rows untuk menghitung total baris di tabel databse*/
                                        if($jumlah == 0){  //jika tidak ada data
                                            ?>
                                        <tr>
                                            <td colspan="6">Tidak Terdapat Data</td>
                                        </tr>
                                        <?php
                                        }else{
                                        //jika ada data di tb_brand
                                        while($a=mysqli_fetch_array($ambildata)){ /*mysql_fetch array untuk mengambil data di setiap field di tabel databse*/
                                        ?>
                                        <tr>
                                            <td><?php echo $posisi=$posisi+1;?></td>
                                            <td><?php echo $a['nama_subkelmapel'];?></td>
                                            <td><?php echo $a['nama_kelmapel'];?></td>
                                            <td><a href="hapus_subkelmapel.php?id_subkelmapel=<?php echo $a['id_subkelmapel'];?>" onclick="return confirm('Yakin akan meghapus data ini')" title="Hapus data"><button class="btn btn-danger btn-sm"><i class="fa fa-trash-o fa-fw"></i> Hapus</button></a>
                                            <a href="edit_subkelmapel.php?id_subkelmapel=<?php echo $a['id_subkelmapel'];?>" title="Edit data"><button class="btn btn-primary btn-sm"><i class="fa fa-pencil-square-o fa-fw"></i> Edit</button> </a>
                                            </td>
                                        </tr>
                                        <?php
                                            }
                                        }
                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                                <!-- /.tabel responsive -->

                                <div class="text-center">
                                    <?php
                                //script paging, untuk menampikan setiap halaman
                                $jml_data = mysqli_num_rows(mysqli_query($conect, "select*from tb_subkelmapel, tb_kelmapel where tb_subkelmapel.id_kelmapel=tb_kelmapel.id_kelmapel order by id_subkelmapel asc"));
                                $JmlHalaman = ceil($jml_data/$batas); //ceil digunakan untuk pembulatan keatas
                                if($jml_data != 0){
                                if ( $pg > 1 ) {
                                $link = $pg-1;
                                $prev = "<a href='?pg=$link'><button name='prev' class='btn btn-primary btn-sm'>Prev</button></a> ";
                                } else {
                                $prev = "<button name='prev' class='btn btn-default btn-sm'>Prev </button> ";
                                }
                                $nmr = '';
                                for ( $i = 1; $i<= $JmlHalaman; $i++ ){

                                if ( $i == $pg ) {
                                $nmr .= "<button name='prev' class='btn btn-primary btn-sm'>$i</button> ";
                                } else {
                                $nmr .= "<a href='?pg=$i'><button name='prev' class='btn btn-default btn-sm'>$i</button></a> ";
                                }
                                }
                                if ( $pg < $JmlHalaman ) {
                                $link = $pg + 1;
                                $next = "<a href='?pg=$link'><button name='prev' class='btn btn-primary btn-sm'>Next</button></a> ";
                                } else {
                                $next = "<button name='prev' class='btn btn-default btn-sm'>Next</button> ";
                                }
                                echo $prev.$nmr.$next;
                                ?>
                                <br><br>
                                <span class="text-muted">Menampilkan <?php echo $jumlah; ?> dari <?php echo $jml_data; ?> Record </span>
                                <?php
                                }
                                ?>
                                </div>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasilnya akan seperti ini

Jalankan di localhost dengan mengetik url contoh localhost/sisfomik/adminweb/subkelmapel.php

Jangan lupa anda harus mengisikan data dulu di data kelompok mapel yang sebelumnya anda buat

subkelmapel

 

Kedua, Buat file baru dengan nama input_subkelmapel.php simpan di folder adminweb

isi dari file input_subkelmapel seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Tambah Data Sub Kelompok Mapel
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Tambah Data Sub Kelompok Mapel
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama
                $kel=mysqli_real_escape_string($conect, $_POST['kel']);  //variabel dari name input nama

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nama)){  //jika field nama kosong
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Masukan Nama </div>";
                }
                elseif($kel == ""){  //jika field nama kosong
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Pilih Kelompok </div>";
                }
                else{
                $save=mysqli_query($conect, "INSERT INTO tb_subkelmapel(id_subkelmapel,id_kelmapel,nama_subkelmapel) VALUES ('','$kel','$nama')");
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Disimpan');document.location='subkelmapel.php'</script>";
                }
                else{  //jika simpan gagal
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Error</div>";
                }

                }
                }
                ?>
                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="subkelmapel.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">
                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <?php echo $error;?>
                            <div class="form-group row">
                            <label class="col-lg-3 control-label">Nama Kelompok Mapel</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama Kelompok" maxlength="30" value="<?php echo $_POST['nama'];?>"/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 control-label">Kelompok Mapel</label>
                            <div class="col-lg-5">
                                <select class="form-control" name="kel" id="kel">
                                    <option value="">-- Pilih --</option>
                                    <?php
                                    $cek=mysqli_query($conect, "select*from tb_kelmapel order by nama_kelmapel");
                                    while($ye=mysqli_fetch_array($cek)){
                                        if($ye['id_kelmapel'] == $_POST['kel']){
                                    ?>
                                    <option value="<?php echo $ye['id_kelmapel'];?>" selected>
                                        <?php echo $ye['nama_kelmapel'];?>
                                    </option>
                                    <?php
                                }else{
                                    ?>
                                    <option value="<?php echo $ye['id_kelmapel'];?>">
                                        <?php echo $ye['nama_kelmapel'];?>
                                    </option>
                                    <?php
                                }
                                    }
                                    ?>

                                </select>
                            </div>
                        </div>

                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasilnya akan seperti ini

input-subkelmapel

Ketiga, Buat file baru dengan nama edit_subkelmapel.php simpan di folder adminweb

isi dari file edit_subkelmapel seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Ubah Data Sub Kelompok Mapel
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Ubah Data Sub Kelompok Mapel
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                $tampildata=mysqli_query($conect, "select*from tb_subkelmapel where id_subkelmapel='$_GET[id_subkelmapel]'");
                $b=mysqli_fetch_array($tampildata);

                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama
                $kel=mysqli_real_escape_string($conect, $_POST['kel']);  //variabel dari name input nama

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nama)){  //jika field nama kosong
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Masukan Nama </div>";
                }
                elseif($kel == ""){  //jika field nama kosong
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Pilih Kelompok </div>";
                }
                else{
                $save=mysqli_query($conect, "UPDATE tb_subkelmapel set id_kelmapel='$kel',nama_subkelmapel='$nama' where id_subkelmapel='$_GET[id_subkelmapel]'");
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Disimpan');document.location='subkelmapel.php'</script>";
                }
                else{  //jika simpan gagal
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Error</div>";
                }

                }
                }
                ?>
                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="subkelmapel.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">
                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <?php echo $error;?>
                            <div class="form-group row">
                            <label class="col-lg-3 control-label">Nama Kelompok Mapel</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama Kelompok" maxlength="30" value="<?php echo $b['nama_subkelmapel'];?>"/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 control-label">Kelompok Mapel</label>
                            <div class="col-lg-5">
                                <select class="form-control" name="kel" id="kel">
                                    <option value="">-- Pilih --</option>
                                    <?php
                                    $cek=mysqli_query($conect, "select*from tb_kelmapel order by nama_kelmapel");
                                    while($ye=mysqli_fetch_array($cek)){
                                        if($ye['id_kelmapel'] == $b['id_kelmapel']){
                                    ?>
                                    <option value="<?php echo $ye['id_kelmapel'];?>" selected>
                                        <?php echo $ye['nama_kelmapel'];?>
                                    </option>
                                    <?php
                                }else{
                                    ?>
                                    <option value="<?php echo $ye['id_kelmapel'];?>">
                                        <?php echo $ye['nama_kelmapel'];?>
                                    </option>
                                    <?php
                                }
                                    }
                                    ?>

                                </select>
                            </div>
                        </div>

                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasilnya akan seperti ini

edit-subkelmapel

Keempat, Buat file baru dengan nama hapus_subkelmapel.php simpan di folder adminweb

isi dari file hapus_subkelmapel seperti ini

<?php
session_start();
//panggil koneksi
include "../assets/relasi/koneksi.php";

$id=$_GET['id_subkelmapel'];  //dapatkan id

if(isset($id)){ //jika ada id
//hapus data di tabel
$hapus=mysqli_query($conect, "DELETE from tb_subkelmapel where id_subkelmapel='$id'");
//jika hapus berhasil
if($hapus){
    echo"<script>alert('Data Berhasil di Hapus');document.location='subkelmapel.php'</script>";
}
else{ //jika gagal
    echo"<script>alert('Error Bos !!');document.location='subkelmapel.php'</script>";
}

}
?>

Oke Selesai

 

 

 

Develindo Web | Tutorial Pemrograman Website