Online Course

DNR06 – Tutorial Membuat Pengaturan Data Siswa di Halaman Admin

Tutorial Membuat Pengaturan Data Siswa di Halaman Admin

Setelah anda mengerjakan DNR05, silahkan anda lanjutkan ke tutorial ini.

Buat folder baru dengan nama siswa di dalam folder images (penting)

Bagian 1 : Buat tabel di database dengan nama tb_siswa

Struktur dari tb_siswa seperti ini

tb-siswa

Bagian 2 : Buat file siswa.php simpan di folder ADMINWEB

Isi dari file siswa.php seperti ini

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

//pemanggilan file navbar
include "setting_navbar.php";
?>
<style type="text/css">
th{
    min-width:70px;
}
</style>
        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Daftar siswa
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar siswa
                            </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">
                            <div class="col-lg-6">
                            <a href="input_siswa.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>
                            <div class="col-lg-6">
                            <!-- form pencarian produk -->
                            <form action="cari_siswa.php" method="get" class="form-inline text-right">
                            <input type="text" class="form-control" name="qw" placeholder="Cari siswa" required>
                            <button type="submit" class="btn btn-primary">Cari</button>
                            </form>
                            <!-- form pencarian produk -->
                            </div>
                            <div style="clear:both;"></div>
                            </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>NIS / NISN</th>
                                                <th>Nama Lengkap</th>
                                                <th>Tempat Lahir</th>
                                                <th>Tanggal Lahir</th>
                                                <th>L/P</th>
                                                <th>Agama</th>
                                                <th>Alamat</th>
                                                <th>Telp</th>
                                                <th>Email</th>
                                                <th>Tahun Masuk</th>
                                                <th>Jurusan</th>
                                                <th>Status</th>
                                                <th>Foto</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 25; /*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_siswa, tb_jurusan where tb_siswa.id_jurusan=tb_jurusan.id_jurusan order by nis_siswa desc 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="16">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['nis_siswa'];?> / <?php echo $a['nisn'];?></td>
                                            <td><?php echo $a['nama_siswa'];?></td>
                                            <td><?php echo $a['tempatlahir_siswa'];?></td>
                                            <td><?php echo tgl_indo($a['tgllahir_siswa']);?></td>
                                            <td><?php echo $a['gender_siswa'];?></td>
                                            <td><?php echo $a['agama_siswa'];?></td>
                                            <td><?php echo $a['alamat_siswa'];?></td>
                                            <td><?php echo $a['telp_siswa'];?></td>
                                            <td><?php echo $a['email_siswa'];?></td>
                                            <td><?php echo $a['tahun_masuk'];?></td>
                                            <td><?php echo $a['kode_jurusan'];?></td>
                                            <td><?php echo $a['status_siswa'];?></td>

                                            <td><img src="<?php echo $hostname;?>/assets/images/siswa/<?php echo $a['foto_siswa'];?>" class="img-thumbnail" style="width:60px; height:60px;"></td>
                                            <td><a href="hapus_siswa.php?nis_siswa=<?php echo $a['nis_siswa'];?>" 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_siswa.php?nis_siswa=<?php echo $a['nis_siswa'];?>" 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_siswa, tb_jurusan where tb_siswa.id_jurusan=tb_jurusan.id_jurusan order by nis_siswa desc"));
                                $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";

?>

Hasil dari file siswa.php seperti ini

daftar-siswa

 

Bagian 3 : Buat file input_siswa.php simpan di folder ADMINWEB

Isi dari file input_siswa.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 Siswa
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Siswa
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama
                $nis=mysqli_real_escape_string($conect, $_POST['nis']);
                $nisn=mysqli_real_escape_string($conect, $_POST['nisn']);
                $email=mysqli_real_escape_string($conect, $_POST['email']);
                $telp=mysqli_real_escape_string($conect, $_POST['telp']);
                $status=mysqli_real_escape_string($conect, $_POST['status']);
                $agama=mysqli_real_escape_string($conect, $_POST['agama']);
                $jurusan=mysqli_real_escape_string($conect, $_POST['jurusan']);
                $tempat=mysqli_real_escape_string($conect, $_POST['tempat']);
                $tgllahir=mysqli_real_escape_string($conect, $_POST['tanggal']);
                $alamat=mysqli_real_escape_string($conect, $_POST['alamat']);
                $gender=mysqli_real_escape_string($conect, $_POST['gender']);
                $tahun=mysqli_real_escape_string($conect, $_POST['tahun']);
                $pass = $tgllahir;

                $foto=$_FILES['foto']['tmp_name'];               //variabel dari temporary foto
                $nama_foto=$_FILES ['foto']['name'];             //variabel dari name input foto
                $type=$_FILES['foto']['type'];                   //variabel dari type foto
                $ukuran=$_FILES['foto']['size'];                 //variabel dari ukuran foto
                $files= strtolower(substr(strrchr($nama_foto,"."),1)); //variabel untuk extensi file

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nis)){  //jika field nama kosong
                $er_nis="<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 NIS Siswa </div>";
                }
                elseif(empty($nisn)){  //jika field nama kosong
                $er_nisn="<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 NISN Siswa </div>";
                }
                elseif(empty($nama)){  //jika field nama kosong
                $er_nama="<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 Siswa </div>";
                }
                elseif(empty($gender)){  //jika field nama kosong
                $er_gender="<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 Gender Siswa </div>";
                }
                elseif($agama == ""){  //jika field nama kosong
                $er_agama="<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 Agama Siswa </div>";
                }
                elseif(empty($tempat)){ //jika field url kosong
                $er_tempat="<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 Tempat Lahir</div>";
                }
                elseif(empty($tgllahir)){ //jika field url kosong
                $er_tgllahir="<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 Tanggal Lahir</div>";
                }
                elseif(empty($email)){ //jika field url kosong
                $er_email="<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 Email Guru</div>";
                }
                elseif(empty($telp)){ //jika field url kosong
                $er_telp="<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 No. Telp</div>";
                }
                elseif(empty($alamat)){ //jika field url kosong
                $er_alamat="<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 Alamat Siswa</div>";
                }
                elseif(empty($jurusan)){ //jika field url kosong
                $er_jurusan="<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 Jurusan siswa</div>";
                }
                elseif(empty($tahun)){ //jika field url kosong
                $er_tahun="<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 Tahun Masuk Siswa</div>";
                }
                elseif($status == ""){ //jika field url kosong
                $er_status="<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 status Siswa</div>";
                }
                elseif(empty($foto)){  //jika foto kosong
                $er_foto="<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 Foto</div>";
                }
                elseif($files !="jpg" && $files !="png"){ //jika foto tidak berekstensi .jpg atau .png
                $er_foto="<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> Format Gambar yang diizinkan hanya .jpg dan .png</div>";
                }
                elseif($ukuran > 2000000){   //jika ukuran lebih besar dari 2MB
                $er_foto="<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> Maksimal ukuran gambar 2MB </div>";
                }
                elseif(strlen($nama_foto) > 100){  //jika jumlah karakter nama foto lebih dari 100 karakter
                $er_foto="<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> Nama File Gambar Mak 100 karakter</div>";
                }
                else{ //jika semua field terpenuhi maka smpan gambar ke folder brand dan simpan data ke tb_brand
                move_uploaded_file($foto,"../assets/images/siswa/$nama_foto");
                $save=mysqli_query($conect, "INSERT INTO tb_siswa (nis_siswa,nama_siswa,alamat_siswa,foto_siswa,email_siswa,telp_siswa,status_siswa,id_jurusan,gender_siswa,tempatlahir_siswa,tgllahir_siswa,tahun_masuk,agama_siswa,pass_siswa,nisn)
                values('$nis','$nama','$alamat','$nama_foto','$email','$telp','$status','$jurusan','$gender','$tempat','$tgllahir','$tahun','$agama','$pass','$nisn')") or die(mysqli_error($conect));
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Ditambahkan');document.location='siswa.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> Penyimpanan Gagal, ulangi lagi</div>";
                }

                }
                }
                if($_POST['gender'] == "L"){
                    $check1='checked';
                }elseif($_POST['gender'] == "P"){
                    $check2='checked';
                }

                if($_POST['status'] == "Aktif"){
                    $aktif='selected';
                }elseif($_POST['status'] == "Non Aktif"){
                    $non='selected';
                }

                if($_POST['agama'] == "Islam"){
                    $islam='selected';
                }elseif($_POST['agama'] == "Kristen"){
                    $kristen='selected';
                }elseif($_POST['agama'] == "Hindu"){
                    $hindu='selected';
                }elseif($_POST['agama'] == "Budha"){
                    $budha='selected';
                }elseif($_POST['agama'] == "Lainnya"){
                    $lain='selected';
                }
                ?>
                <!-- .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="siswa.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

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

                            <!-- /.form menggunakan form group, pelajari cara membuat form di bootstrap-->

                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NIS</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nis" id="nis" placeholder="NIS" maxlength="30" value="<?php echo $_POST['nis'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nis;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NISN</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nisn" id="nisn" placeholder="NISN" maxlength="50" value="<?php echo $_POST['nisn'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nisn;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Nama Siswa</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama Lengkap" maxlength="60" value="<?php echo $_POST['nama'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nama;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Gender</label>
                                                <div class="col-lg-5">
                                                    <div class="radio">
                                                    <?php echo'
                                                        <label>
                                                            <input type="radio" name="gender" value="L" '.$check1.'/> Laki
                                                        </label>

                                                        <label>
                                                            <input type="radio" name="gender" value="P" '.$check2.'/> Perempuan
                                                        </label> ';?>
                                                    </div>

                                                </div>
                                            </div>
                                             <?php echo $er_gender;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Agama</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="agama">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="Islam" '.$islam.'>Islam</option>
                                                        <option value="Kristen" '.$kristen.'>Kristen</option>
                                                        <option value="Hindu" '.$hindu.'>Hindu</option>
                                                        <option value="Budha" '.$budha.'>Budha</option>
                                                        <option value="Lainnya" '.$lain.'>Lainnya</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_agama;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tempat Lahir</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tempat" id="tempat" placeholder="Tempat Lahir" maxlength="50" value="<?php echo $_POST['tempat'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_tempat;?>


                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tanggal Lahir</label>
                                                <div class="col-lg-5 date">
                                                    <div class="input-group input-append date" id="datePicker">
                                                        <input type="text" class="form-control" name="tanggal" id="tanggal" placeholder="Tanggal Lahir" value="<?php echo $_POST['tanggal'];?>"/>
                                                        <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php echo $er_tgllahir;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Email</label>
                                                <div class="col-lg-5">
                                                    <input type="email" class="form-control" name="email" id="email" placeholder="Email" maxlength="60" value="<?php echo $_POST['email'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_email;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">No. Telp</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="telp" id="telp" placeholder="No Telp" maxlength="15" value="<?php echo $_POST['telp'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_telp;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Alamat Dusun / Nama Jalan</label>
                                                <div class="col-lg-5">
                                                    <textarea class="form-control" name="alamat" id="alamat" placeholder="Nama Dusun / Nama Jalan" rows="4"><?php echo $_POST['alamat'];?></textarea>
                                                </div>
                                            </div>
                                            <?php echo $er_alamat;?>
                                            <div class="form-group row">
                                <label class="col-lg-3">Jurusan</label>
                                <div class="col-lg-5">
                                <select name="jurusan" class="form-control">
                                        <option value="">Pilih Jurusan</option>
                                        <?php $jurusan=mysqli_query($conect, "select *from tb_jurusan");
                                        while($d=mysqli_fetch_array($jurusan)){
                                        if($d['id_jurusan']== $_POST['jurusan']){
                                        echo "
                                        <option value='$d[id_jurusan]' selected>$d[nama_jurusan]</option>";
                                        }
                                        else{
                                        echo "
                                        <option value='$d[id_jurusan]'>$d[nama_jurusan]</option>";
                                        }

                                        }
                                        ?> </select>
                                        </div>
                            </div>
                            <?php echo $er_jurusan;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tahun Masuk</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tahun" id="tahun" placeholder="Tahun Masuk" maxlength="5" value="<?php echo $_POST['tahun'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_tahun;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Status Siswa</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="status">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="Aktif" '.$aktif.'>Aktif</option>
                                                        <option value="Non Aktif" '.$non.'>Non Aktif</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_status;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Foto</label>
                                                <div class="col-lg-5">
                                                    <input type="file" class="form-control" name="foto" id="foto" />

                                                </div>
                                            </div>
                                            <?php echo $er_foto;?>
                                            <hr>
                                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                                <!-- /.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";

?>

Hasil dari file input_siswa.php seperti ini

input-siswa

 

Bagian 4 : Buat file edit_siswa.php simpan di folder Adminweb

Isi dari file edit_siswa.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 Siswa
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Siswa
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

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

                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama
                $nis=mysqli_real_escape_string($conect, $_POST['nis']);
                $nisn=mysqli_real_escape_string($conect, $_POST['nisn']);
                $email=mysqli_real_escape_string($conect, $_POST['email']);
                $telp=mysqli_real_escape_string($conect, $_POST['telp']);
                $status=mysqli_real_escape_string($conect, $_POST['status']);
                $agama=mysqli_real_escape_string($conect, $_POST['agama']);
                $jurusan=mysqli_real_escape_string($conect, $_POST['jurusan']);
                $tempat=mysqli_real_escape_string($conect, $_POST['tempat']);
                $tgllahir=mysqli_real_escape_string($conect, $_POST['tanggal']);
                $alamat=mysqli_real_escape_string($conect, $_POST['alamat']);
                $gender=mysqli_real_escape_string($conect, $_POST['gender']);
                $tahun=mysqli_real_escape_string($conect, $_POST['tahun']);
                $lama=mysqli_real_escape_string($conect, $_POST['lama']);
                $pass = $tgllahir;

                $foto=$_FILES['foto']['tmp_name'];               //variabel dari temporary foto
                $nama_foto=$_FILES ['foto']['name'];             //variabel dari name input foto
                $type=$_FILES['foto']['type'];                   //variabel dari type foto
                $ukuran=$_FILES['foto']['size'];                 //variabel dari ukuran foto
                $files= strtolower(substr(strrchr($nama_foto,"."),1)); //variabel untuk extensi file

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nis)){  //jika field nama kosong
                $er_nis="<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 NIS Siswa </div>";
                }
                elseif(empty($nisn)){  //jika field nama kosong
                $er_nisn="<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 NISN Siswa </div>";
                }
                elseif(empty($nama)){  //jika field nama kosong
                $er_nama="<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 Siswa </div>";
                }
                elseif(empty($gender)){  //jika field nama kosong
                $er_gender="<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 Gender Siswa </div>";
                }
                elseif($agama == ""){  //jika field nama kosong
                $er_agama="<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 Agama Siswa </div>";
                }
                elseif(empty($tempat)){ //jika field url kosong
                $er_tempat="<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 Tempat Lahir</div>";
                }
                elseif(empty($tgllahir)){ //jika field url kosong
                $er_tgllahir="<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 Tanggal Lahir</div>";
                }
                elseif(empty($email)){ //jika field url kosong
                $er_email="<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 Email Guru</div>";
                }
                elseif(empty($telp)){ //jika field url kosong
                $er_telp="<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 No. Telp</div>";
                }
                elseif(empty($alamat)){ //jika field url kosong
                $er_alamat="<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 Alamat Siswa</div>";
                }
                elseif(empty($jurusan)){ //jika field url kosong
                $er_jurusan="<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 Jurusan siswa</div>";
                }
                elseif(empty($tahun)){ //jika field url kosong
                $er_tahun="<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 Tahun Masuk Siswa</div>";
                }
                elseif($status == ""){ //jika field url kosong
                $er_status="<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 status Siswa</div>";
                }
                else{
                if(empty($foto)){
                $save=mysqli_query($conect, "UPDATE tb_siswa set nama_siswa='$nama',alamat_siswa='$alamat',email_siswa='$email',telp_siswa='$telp',status_siswa='$status',id_jurusan='$jurusan',gender_siswa='$gender',tempatlahir_siswa='$tempat',tgllahir_siswa='$tgllahir',tahun_masuk='$tahun',agama_siswa='$agama',pass_siswa='$pass',nisn='$nisn' where nis_siswa='$_GET[nis_siswa]'") or die(mysqli_error($conect));
                if($save){   //save
                echo " <script>alert('Data Berhasil Diubah');document.location='siswa.php'</script>";
                }
                else{    //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> Perubahan Gagal</div>";
                }
                }
                else{ //jika foto ikut diubah maka
                if($files !="jpg" && $files !="png"){ //jika foto tidak berekstensi .jpg atau .png
                $er_foto="<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> Format Gambar yang diizinkan hanya .jpg dan .png</div>";
                }
                elseif($ukuran > 2000000){   //jika ukuran lebih besar dari 2MB
                $er_foto="<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> Maksimal ukuran gambar 2MB </div>";
                }
                elseif(strlen($nama_foto) > 100){  //jika jumlah karakter nama foto lebih dari 100 karakter
                $er_foto="<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> Nama File Gambar Mak 100 karakter</div>";
                }
                else{ //jika semua field terpenuhi maka simpan gambar ke folder dan simpan data ke tabel

                unlink('../assets/images/siswa/'.$lama); //hapus foto lama di folder
                move_uploaded_file($foto,"../assets/images/siswa/$nama_foto");  //upload foto baru
                //simpan ke tabel database
                $save=mysqli_query($conect, "UPDATE tb_siswa set nama_siswa='$nama',alamat_siswa='$alamat',foto_siswa='$nama_foto',email_siswa='$email',telp_siswa='$telp',status_siswa='$status',id_jurusan='$jurusan',gender_siswa='$gender',tempatlahir_siswa='$tempat',tgllahir_siswa='$tgllahir',tahun_masuk='$tahun',agama_siswa='$agama',pass_siswa='$pass',nisn='$nisn' where nis_siswa='$_GET[nis_siswa]'") or die(mysqli_error($conect));
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Diubah');document.location='siswa.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> Perubahan gagal, ulangi lagi</div>";
                }
                }
                }

                }
                }
                

                if($b['gender_siswa'] == "L"){
                    $check1='checked';
                }elseif($b['gender_siswa'] == "P"){
                    $check2='checked';
                }

                if($b['status_siswa'] == "Aktif"){
                    $aktif='selected';
                }elseif($b['status_siswa'] == "Non Aktif"){
                    $non='selected';
                }

                if($b['agama_siswa'] == "Islam"){
                    $islam='selected';
                }elseif($b['agama_siswa'] == "Kristen"){
                    $kristen='selected';
                }elseif($b['agama_siswa'] == "Hindu"){
                    $hindu='selected';
                }elseif($b['agama_siswa'] == "Budha"){
                    $budha='selected';
                }elseif($b['agama_siswa'] == "Lainnya"){
                    $lain='selected';
                }
                ?>
                <!-- .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="siswa.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

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

                            <!-- /.form menggunakan form group, pelajari cara membuat form di bootstrap-->

                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NIS</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nis" id="nis" placeholder="NIS" maxlength="30" value="<?php echo $b['nis_siswa'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nis;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NISN</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nisn" id="nisn" placeholder="NISN" maxlength="50" value="<?php echo $b['nisn'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nisn;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Nama Siswa</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama Lengkap" maxlength="60" value="<?php echo $b['nama_siswa'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nama;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Gender</label>
                                                <div class="col-lg-5">
                                                    <div class="radio">
                                                    <?php echo'
                                                        <label>
                                                            <input type="radio" name="gender" value="L" '.$check1.'/> Laki
                                                        </label>

                                                        <label>
                                                            <input type="radio" name="gender" value="P" '.$check2.'/> Perempuan
                                                        </label> ';?>
                                                    </div>

                                                </div>
                                            </div>
                                             <?php echo $er_gender;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Agama</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="agama">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="Islam" '.$islam.'>Islam</option>
                                                        <option value="Kristen" '.$kristen.'>Kristen</option>
                                                        <option value="Hindu" '.$hindu.'>Hindu</option>
                                                        <option value="Budha" '.$budha.'>Budha</option>
                                                        <option value="Lainnya" '.$lain.'>Lainnya</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_agama;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tempat Lahir</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tempat" id="tempat" placeholder="Tempat Lahir" maxlength="50" value="<?php echo $b['tempatlahir_siswa'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_tempat;?>


                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tanggal Lahir</label>
                                                <div class="col-lg-5 date">
                                                    <div class="input-group input-append date" id="datePicker">
                                                        <input type="text" class="form-control" name="tanggal" id="tanggal" placeholder="Tanggal Lahir" value="<?php echo $b['tgllahir_siswa'];?>"/>
                                                        <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php echo $er_tgllahir;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Email</label>
                                                <div class="col-lg-5">
                                                    <input type="email" class="form-control" name="email" id="email" placeholder="Email" maxlength="60" value="<?php echo $b['email_siswa'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_email;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">No. Telp</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="telp" id="telp" placeholder="No Telp" maxlength="15" value="<?php echo $b['telp_siswa'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_telp;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Alamat Dusun / Nama Jalan</label>
                                                <div class="col-lg-5">
                                                    <textarea class="form-control" name="alamat" id="alamat" placeholder="Nama Dusun / Nama Jalan" rows="4"><?php echo $b['alamat_siswa'];?></textarea>
                                                </div>
                                            </div>
                                            <?php echo $er_alamat;?>
                                            <div class="form-group row">
                                <label class="col-lg-3">Jurusan</label>
                                <div class="col-lg-5">
                                <select name="jurusan" class="form-control">
                                        <option value="">Pilih Jurusan</option>
                                        <?php $jurusan=mysqli_query($conect, "select *from tb_jurusan");
                                        while($d=mysqli_fetch_array($jurusan)){
                                        if($d['id_jurusan']== $b['id_jurusan']){
                                        echo "
                                        <option value='$d[id_jurusan]' selected>$d[nama_jurusan]</option>";
                                        }
                                        else{
                                        echo "
                                        <option value='$d[id_jurusan]'>$d[nama_jurusan]</option>";
                                        }

                                        }
                                        ?> </select>
                                        </div>
                            </div>
                            <?php echo $er_jurusan;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tahun Masuk</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tahun" id="tahun" placeholder="Tahun Masuk" maxlength="5" value="<?php echo $b['tahun_masuk'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_tahun;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Status Siswa</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="status">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="Aktif" '.$aktif.'>Aktif</option>
                                                        <option value="Non Aktif" '.$non.'>Non Aktif</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_status;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Foto</label>
                                                <div class="col-lg-5">
                                                    <input type="file" class="form-control" name="foto" id="foto" />
                                                    <input type="hidden" class="form-control" name="lama" value="<?php echo $b['foto_siswa'];?>"/>

                                                </div>
                                            </div>
                                            <?php echo $er_foto;?>
                                            <hr>
                                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                                <!-- /.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";

?>

Hasil dari file edit_siswa.php seperti ini

edit-siswa

Bagian 6 : Buat file cari_siswa.php simpan di folder Adminweb

Isi dari file cari_siswa.php seperti ini

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

//pemanggilan file navbar
include "setting_navbar.php";
?>
<style type="text/css">
th{
    min-width:70px;
}
</style>
        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Daftar siswa
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar siswa
                            </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">
                            <div class="col-lg-6">
                            <a href="input_siswa.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>
                            <div class="col-lg-6">
                            <!-- form pencarian produk -->
                            <form action="cari_siswa.php" method="get" class="form-inline text-right">
                            <input type="text" class="form-control" name="qw" placeholder="Cari siswa" required>
                            <button type="submit" class="btn btn-primary">Cari</button>
                            </form>
                            <!-- form pencarian produk -->
                            </div>
                            <div style="clear:both;"></div>
                            </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>NIS / NISN</th>
                                                <th>Nama Lengkap</th>
                                                <th>Tempat Lahir</th>
                                                <th>Tanggal Lahir</th>
                                                <th>L/P</th>
                                                <th>Agama</th>
                                                <th>Alamat</th>
                                                <th>Telp</th>
                                                <th>Email</th>
                                                <th>Tahun Masuk</th>
                                                <th>Jurusan</th>
                                                <th>Status</th>
                                                <th>Foto</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 25; /*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_siswa, tb_jurusan where tb_siswa.id_jurusan=tb_jurusan.id_jurusan and nama_siswa LIKE '%$_GET[qw]%' OR tb_siswa.id_jurusan=tb_jurusan.id_jurusan and nis_siswa LIKE '%$_GET[qw]%' order by nis_siswa desc 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="16">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['nis_siswa'];?> / <?php echo $a['nisn'];?></td>
                                            <td><?php echo $a['nama_siswa'];?></td>
                                            <td><?php echo $a['tempatlahir_siswa'];?></td>
                                            <td><?php echo tgl_indo($a['tgllahir_siswa']);?></td>
                                            <td><?php echo $a['gender_siswa'];?></td>
                                            <td><?php echo $a['agama_siswa'];?></td>
                                            <td><?php echo $a['alamat_siswa'];?></td>
                                            <td><?php echo $a['telp_siswa'];?></td>
                                            <td><?php echo $a['email_siswa'];?></td>
                                            <td><?php echo $a['tahun_masuk'];?></td>
                                            <td><?php echo $a['kode_jurusan'];?></td>
                                            <td><?php echo $a['status_siswa'];?></td>

                                            <td><img src="<?php echo $hostname;?>/assets/images/siswa/<?php echo $a['foto_siswa'];?>" class="img-thumbnail" style="width:60px; height:60px;"></td>
                                            <td><a href="hapus_siswa.php?nip_siswa=<?php echo $a['nis_siswa'];?>" 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_siswa.php?nip_siswa=<?php echo $a['nis_siswa'];?>" 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_siswa, tb_jurusan where tb_siswa.id_jurusan=tb_jurusan.id_jurusan and nama_siswa LIKE '%$_GET[qw]%' OR tb_siswa.id_jurusan=tb_jurusan.id_jurusan and nis_siswa LIKE '%$_GET[qw]%'order by nis_siswa desc"));
                                $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";

?>

 

LATIHAN

Buat file hapus_siswa.php yang berfungsi menghapus data siswa di tb_siswa dan menghapus foto siswa yang berada di folder siswa.

(silahkan anda contoh hapus_guru, mirip seperti itu)

Hasilnya akan seperti ini

hpaus-siswa

 

Good Job !

 

 

 

 

Develindo Web | Tutorial Pemrograman Website