Catatan :
6. Select * from adalah perintah untuk mengambil data dari tabel. user adalah
nama tabel yang kita gunakan untuk membuat akun login admin, nama tabel (user)
dapat diganti sesuai dengan keinginan kita.
<?php
include "../koneksi.php";
?>
<?php
$nik = $_POST['nik'];
$nama_karyawan = $_POST['nama_karyawan'];
$jabatan = $_POST['jabatan'];
$tgl_masuk = $_POST['tgl_masuk'];
$divisi = $_POST['divisi'];
$query_insert_ok =mysqli_query($connect,$query_insert);
if ($query_insert_ok){
header("location:home.php?pesan=SuksesTambah");
}else{
header("location:home.php?pesan=GagalTambah");
}
?>
<?php
include "../koneksi.php";
?>
<?php
if(isset($_GET['pesan'])){
if($_GET['pesan'] == "gagal"){
echo "Login gagal! username dan password salah!";
}else if($_GET['pesan'] == "logout"){
echo "Anda telah berhasil logout";
}else if($_GET['pesan'] == "belum_login"){
echo "Anda harus login untuk mengakses halaman admin";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DAFTAR KARYAWAN</title>
<style>
body
{
background-image: url(../dddd.jpg);
}
</style>
<meta charset="utf-8">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h3 class="text-center">Halaman Daftar Karyawan PT NUSANTARA</h3>
<a class="btn btn-primary" href="tambah_data.php" role="button">Tambah</a>
<a class="btn btn-danger" href="../logout.php" role="button">Logout</a>
<!--INSERT TABLE-->
<table class="table table-striped">
<thead>
<tr>
<th>No</th>
<th>NIK</th>
<th>Nama Karyawan</th>
<th>Jabatan</th>
<th>Tgl Masuk</th>
<th>Divisi</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$no=1;
$query="select * from tb_karyawan";
if (!$query_r){
printf("eror: %s\n", mysqli_error($connect));
exit();}
while ($result = mysqli_fetch_array($query_r))
{
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $result ['nik'];?></td>
<td><?php echo $result ['nama_karyawan'];?></td>
<td><?php echo $result ['jabatan'];?></td>
<td><?php echo $result ['tgl_masuk'];?></td>
<td><?php echo $result ['divisi'];?></td>
<td>
<a class="btn btn-success" href="update_data.php?id=<?php echo
$result['id'];?>">Edit</a>
| <a class="btn btn-danger" href="delete.php?id=<?php echo
$result['id'];?>">Delete</a>
</td>
</tr>
<?php
$no++;
}
?>
</tbody>
</table>
</div>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></
script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
</div>
</body>
</html>