Assalammu'alaikum Warahmatullahi Wabarakatuh
Oke sekarang saya akan melanjutkan tutorial terakhir, yakni proses hapus.. Berikut adalah tampilan daftar_login.php
dan berikut script lengkapnya :
<html>
<head>
<title>Ujian Back End</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" href="icon_thejak.ico" type="image/x-icon">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="home.php">Beranda</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="daftar_korwil.php">Kelola Daftar Korwil<span class="sr-only">(current)</span></a></li>
<li><a href="#">Kelola Jadwal Tour</a></li>
<li><a href="#">Profil Jakmania</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Produk Distro<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Jersey</a></li>
<li><a href="#">Jaket</a></li>
<li><a href="#">Atribut</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Sepatu</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Login Anggota</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Pengaturan <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="logout.php">Logout</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<?php
if(isset($_GET['pesan'])){
$pesan = $_GET['pesan'];
if($pesan == "input"){
echo "Data berhasil di input.";
}else if($pesan == "update"){
echo "Data berhasil di update.";
}else if($pesan == "hapus"){
echo "Data berhasil di hapus.";
}
}
?>
<br>
<a href="tambah.php" class="btn btn-warning btn-small">Tambah</a>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th><center>No</th></center>
<th><center>Kode</center></th>
<th><center>Nama</center></th>
<th><center>Wilayah</center></th>
<th><center>Ketua Korwil</center></th>
<th><center>Jumlah Anggota</center></th>
<th><center>Opsi</center></th>
</tr>
<?php
include "koneksi.php";
$query_mysql = mysql_query("SELECT * FROM backend_jakmania_korwil")or die(mysql_error());
$nomor = 1;
while($data = mysql_fetch_array($query_mysql)){
?>
<tr>
<td><center><?php echo $nomor++; ?></center></td>
<td><center><?php echo $data['kode']; ?></center></td>
<td><center><?php echo $data['nama']; ?></center></td>
<td><center><?php echo $data['wilayah']; ?></center></td>
<td><center><?php echo $data['ketua']; ?></center></td>
<td><center><?php echo $data['jml']; ?></center></td>
<td><center>
<a class="edit" href="ubah.php?kode=<?php echo $data['kode']; ?>">Edit</a> |
<a class="hapus" onclick="javascript: return confirm('Anda yakin hapus ?')" href="hapus.php?kode=<?php echo $data['kode']; ?>">Hapus</a>
</center></td>
</tr>
<?php } ?>
</table>
</div>
<br>
<div class="panel-footer">
<center>Website Pembelajaran Dasar</center>
</div>
</body>
</html>
Dan berikut adalah tampilan apabila kita klik hapus
Berikut adalah scriptnya dan beri nama
hapus.php
<?php
include 'koneksi.php';
$id = $_GET['kode'];
mysql_query("DELETE FROM backend_jakmania_korwil WHERE kode='$kode'")or die(mysql_error());
header("location:daftar_korwil.php?pesan=hapus");
?>
Maka apabila berhasil akan seperti berikut :
Oke selesai
Terimakasih dan semoga bermanfaat.. Dan ini baru desain simple setelah ini saya akan mensempurnakan tampilannya yaa,, Oke sukses untuk kita semua
Wassalammu'alaikum Warahmatullahi Wabarakatuh