Skip to content

Instantly share code, notes, and snippets.

@firdaushqq
Created March 21, 2021 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save firdaushqq/447c1ebcc4235facdcd8d993ed76ac54 to your computer and use it in GitHub Desktop.
Save firdaushqq/447c1ebcc4235facdcd8d993ed76ac54 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="assets/media/js/jquery.min.js"></script>
<script src="assets/media/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="assets/media/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/media/plugins/toastr/toastr.min.css">
<script src="assets/media/plugins/toastr/toastr.min.js"></script>
<link rel="icon" type="image/gif" href="media/image/favicon.png">
<title>Data Siswa | Firdaus Haqiqi XI RPL 3</title>
<style>
<?php include 'assets/index.css'; ?>
</style>
</head>
<body>
<h1 class="centertext">Data Siswa</h1>
<div class="search-container">
<form class="search" method="GET" action="index.php">
<div class="search-title">
Tulis data yang anda cari
</div>
<input class="search-in" type="text" name="search" value="<?= @$search ?>">
<button class="search-btn" type="submit">Cari</button>
</form>
<form action="index.php">
<div class="reset-container">
<button class="reset-btn" type="submit">
<a href="index.php">Reset List</a>
</button>
</div>
</form>
</div>
<table class="table-content" border="1">
<thread>
<tr>
<th scope="col">No.</th>
<th scope="col">
Foto<br>
</th>
<th scope="col">
NIS<br>
<a href="index.php?sort=nis&order=asc">▲</a>
<a href="index.php?sort=nis&order=desc">▼</a>
</th>
<th scope="col">
Nama Lengkap<br>
<a href="index.php?sort=nama_lengkap&order=asc">▲</a>
<a href="index.php?sort=nama_lengkap&order=desc">▼</a>
</th>
<th scope="col">
Jenis Kelamin<br>
<a href="index.php?sort=jenis_kelamin&order=asc">▲</a>
<a href="index.php?sort=jenis_kelamin&order=desc">▼</a>
</th>
<th scope="col">
Kelas<br>
<a href="index.php?sort=kelas&order=asc">▲</a>
<a href="index.php?sort=kelas&order=desc">▼</a>
</th>
<th scope="col">
Jurusan<br>
<a href="index.php?sort=jurusan&order=asc">▲</a>
<a href="index.php?sort=jurusan&order=desc">▼</a>
</th>
<th scope="col">
Alamat<br>
<a href="index.php?sort=alamat&order=asc">▲</a>
<a href="index.php?sort=alamat&order=desc">▼</a>
</th>
<th scope="col">
Gol Darah<br>
<a href="index.php?sort=gol_darah&order=asc">▲</a>
<a href="index.php?sort=gol_darah&order=desc">▼</a>
</th>
<th scope="col">
Nama Ibu Kandung<br>
<a href="index.php?sort=nama_ibu_kandung&order=asc">▲</a>
<a href="index.php?sort=nama_ibu_kandung&order=desc">▼</a>
</th>
<th scope="col">Control</th>
</tr>
</thread>
<tbody>
<?php
$i = 1;
while ($siswa = $listSiswa->fetch_array()) {
?>
<tr>
<td scope="row"><?= $i++; ?></td>
<td>
<?php if (!empty($siswa['file'])) { ?>
<img width="90" height="90" src="<?php echo base_url() ?>/assets/image/<?php echo $siswa['file'] ?>">
<?php } else { ?>
<img width="90" height="90" src="assets/img/ava1.png">
<?php } ?>
</td>
<td><?= $siswa['nis']; ?></td>
<td><?= $siswa['nama_lengkap']; ?></td>
<td><?= $siswa['jenis_kelamin']; ?></td>
<td><?= $siswa['kelas']; ?></td>
<td><?= $siswa['jurusan']; ?></td>
<td><?= $siswa['alamat']; ?></td>
<td><?= $siswa['gol_darah']; ?></td>
<td><?= $siswa['nama_ibu_kandung']; ?></td>
<td>
<a href="edit.php?nis=<?= $siswa["nis"]; ?>" class="btn-edit badge badge-primary">Edit</a>
<a class="btn-delete btnDelete badge badge-danger" href="delete.php?nis=<?= $siswa["nis"]; ?>">Delete</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
<form action="tambah.php">
<button type="submit" class="btn-btm">
<a href="tambah.php" class="add">Tambah Data</a>
</button><br>
</form>
<form action="logout.php">
<button type="submit" class="btn-btm">
<a href = "logout.php" class="out"> Logout </a>
</button>
</form>
<div class="modal fade" tabindex=:"-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" arial-label="Close" ><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btnYa" name="button">Ya</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" name="button">Tidak</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$(".btnDelete").on("click", function(e) {
e.preventDefault();
var nama = $(this).parent().parent().children() [3];
nama = $(nama).html();
var tr = $(this).parent().parent();
$(".modal").modal("show");
$(".modal-title").html("Konfirmasi");
$(".modal-body").html("Anda yakin ingin menghapus data <b>" + nama + "</b>?");
var href = $(this).attr('href');
$('.btnYa').off();
$('.btnYa').on('click', function() {
$.ajax({
'url' : href,
'type' : 'POST',
'success' : function(result) {
if(result == 1) {
$(".modal").modal("hide");
tr.fadeOut();
toastr.success("Data berhasil dihapus", "Informasi");
} else {
$(".modal").modal("hide");
toastr.error("Data tidak bisa dihapus");
}
}
})
})
})
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment