Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Edit data dengan modal bootstrap tidak terbaca. exp. "id" tidak tampil di window modal.
<?php
Include "koneksi.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">
<title>Data Anggota Koperasi</title>
<link rel="stylesheet" href="assets/css/bootstrap.css">
<link rel="stylesheet" href="assets/datatables/DataTables-1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="assets/fontawesome/css/all.min.css">
<link rel="stylesheet" href="assets/datatables/buttons-1.6.3/css/buttons.dataTables.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h3 align="center">ANGGOTA KOPERASI M3</h3>
<table id="anggota" class="table table-striped table-hover table-bordered
display-wrap" style="width:100%">
<thead>
<tr>
<th>No</th>
<th>Nik</th>
<th>Nama</th>
<th>Alamat Tinggal</th>
<th>Tgl.Lahir</th>
<th>Divisi</th>
<th>No Hp.</th>
<th>Tgl Aktifasi</th>
<th>Non Aktif</th>
<th>Photo Profil</th>
<th>Status</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody class="table">
<?php
$tampil = mysqli_query($koneksi,"select * from profilanggota");
$nomor=1;
while ($data= mysqli_fetch_assoc($tampil))
{ ?>
<tr>
<td><?php echo $nomor++;?></td>
<td><?php echo $data['nik'];?></td>
<td><?php echo $data['nama'];?></td>
<td><?php echo $data['alamat'];?></td>
<td><?php echo date('d F y',strtotime($data['tgl_lahir']));?></td>
<td><?php echo $data['divisi'];?></td>
<td><?php echo $data['no_hp'];?></td>
<td><?php echo date('d F y',strtotime($data['tgl_masuk']));?></td>
<td><?php echo date('d F y',strtotime($data['tgl_lahir']));?></td>
<td><?php echo $data['id'];?></td>
<td><?php echo $data['status'];?></td>
<td>
<button type="button" class="btn btn-info btn-sm" data-toggle="modal"
data-target="#editanggota<?php echo $data['id'];?>"><span><i class="fas fas fa-edit"></i></span></button>
<a href="#profilanggota?hal=hapus&id=<?=@$data['id']?>" class="btn btn-danger btn-sm" name="bhapus"><span><i class="fas fa-trash"></i></span></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#tambahanggota"><span><i class="fas fa-user-plus"></i>Tambah</span></button>
</div>
</div>
<!--
MODAL TAMBAH
-->
<div class="modal fade" id="tambahanggota" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header shadow p-2 mb-2 bg-secondary rounded">
<h5 class="modal-title text-green">Bio Data Anggota
<span class="badge badge-warning text-danger">New</span></h5>
<button type="button" class="close text-danger" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<!--
MODAL EDIT
-->
<div class="modal fade" id="editanggota<?php echo $data['id'];?>" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header shadow p-2 mb-2 bg-secondary rounded">
<h5 class="modal-title text-green">Bio Data Anggota
<span class="badge badge-warning text-danger">Update</span></h5>
<button type="button" class="close text-danger" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<?php
$id=$data['id'];
echo "id =".$id;
?>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
<script src="assets/jquery/3.5.1/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/datatables/DataTables-1.10.21/js/jquery.dataTables.min.js"></script>
<script src="assets/fontawesome/js/all.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/dataTables.buttons.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/buttons.flash.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/buttons.html5.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/buttons.print.min.js"></script>
<!--
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
-->
</body>
<script type="text/javascript">
$(document).ready(function() {
$('#anggota').DataTable({
dom: 'Bfrtip',
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.19/i18n/Indonesian.json"
},
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"scrollY": 300,
"scrollX": true
});
} );
</script>
</html>
1 Jawaban:
<div>Coba ganti scriptnya menjadi ini :<br><br></div><pre><?php include "koneksi.php"; ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">
&lt;title&gt;Data Anggota Koperasi&lt;/title&gt;
&lt;link rel="stylesheet" href="assets/css/bootstrap.css"&gt;
&lt;link rel="stylesheet" href="assets/datatables/DataTables-1.10.21/css/jquery.dataTables.min.css"&gt;
&lt;link rel="stylesheet" href="assets/fontawesome/css/all.min.css"&gt;
&lt;link rel="stylesheet" href="assets/datatables/buttons-1.6.3/css/buttons.dataTables.min.css"&gt;
</head> <body>
<div class="container"> <div class="row"> <div class="col-sm-12"> <h3 align="center">ANGGOTA KOPERASI M3</h3> <table id="anggota" class="table table-striped table-hover table-bordered display-wrap" style="width:100%"> <thead> <tr> <th>No</th> <th>Nik</th> <th>Nama</th> <th>Alamat Tinggal</th> <th>Tgl.Lahir</th> <th>Divisi</th> <th>No Hp.</th> <th>Tgl Aktifasi</th> <th>Non Aktif</th> <th>Photo Profil</th> <th>Status</th> <th>Tindakan</th> </tr> </thead> <tbody class="table"> <?php $tampil = mysqli_query($koneksi,"select * from profilanggota"); $nomor=1; while ($data= mysqli_fetch_assoc($tampil)) { ?> <tr> <td><?php echo $nomor++;?></td> <td><?php echo $data['nik'];?></td> <td><?php echo $data['nama'];?></td> <td><?php echo $data['alamat'];?></td> <td><?php echo date('d F y',strtotime($data['tgl_lahir']));?></td> <td><?php echo $data['divisi'];?></td> <td><?php echo $data['no_hp'];?></td> <td><?php echo date('d F y',strtotime($data['tgl_masuk']));?></td> <td><?php echo date('d F y',strtotime($data['tgl_lahir']));?></td> <td><?php echo $data['id'];?></td> <td><?php echo $data['status'];?></td> <td>
&lt;button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#editanggota&lt;?php echo $data['id'];?&gt;"&gt;
&lt;span&gt;&lt;i class="fas fas fa-edit"&gt;&lt;/i&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;a href="#profilanggota?hal=hapus&amp;id=&lt;?php echo $data['id']; ?&gt;" class="btn btn-danger btn-sm" name="bhapus"&gt;
&lt;span&gt;&lt;i class="fas fa-trash"&gt;&lt;/i&gt;&lt;/span&gt;
&lt;/a&gt;
&lt;!-- MODAL EDIT --&gt;
&lt;div class="modal fade" id="editanggota&lt;?php echo $data['id'];?&gt;" tabindex="-1" role="dialog"&gt;
&lt;div class="modal-dialog"&gt;
&lt;div class="modal-content"&gt;
&lt;div class="modal-header shadow p-2 mb-2 bg-secondary rounded"&gt;
&lt;h5 class="modal-title text-green"&gt;Bio Data Anggota
&lt;span class="badge badge-warning text-danger"&gt;Update&lt;/span&gt;&lt;/h5&gt;
&lt;button type="button" class="close text-danger" data-dismiss="modal" aria-label="Close"&gt;
&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
&lt;/div&gt;
&lt;div class="modal-body"&gt;
&lt;?php
$id=$data['id'];
echo "id =".$id;
?&gt;
&lt;/div&gt;
&lt;div class="modal-footer"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php } ?&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;button type="button" class="btn btn-success" data-toggle="modal" data-target="#tambahanggota"&gt;&lt;span&gt;&lt;i class="fas fa-user-plus"&gt;&lt;/i&gt;Tambah&lt;/span&gt;&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
<!-- MODAL TAMBAH -->
<div class="modal fade" id="tambahanggota" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header shadow p-2 mb-2 bg-secondary rounded">
<h5 class="modal-title text-green">Bio Data Anggota
<span class="badge badge-warning text-danger">New</span></h5>
<button type="button" class="close text-danger" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
</div>
<div class="modal-body">
&lt;/div&gt;
&lt;div class="modal-footer"&gt;
&lt;/div&gt;
&lt;/div&gt;
</div> </div>
</div>
<script src="assets/jquery/3.5.1/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/datatables/DataTables-1.10.21/js/jquery.dataTables.min.js"></script>
<script src="assets/fontawesome/js/all.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/dataTables.buttons.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/buttons.flash.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/buttons.html5.min.js"></script>
<script src="assets/datatables/buttons-1.6.3/js/buttons.print.min.js"></script>
<!--
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
-->
</body>
&lt;script type="text/javascript"&gt;
$(document).ready(function() {
$('#anggota').DataTable({
dom: 'Bfrtip',
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.19/i18n/Indonesian.json"
},
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"scrollY": 300,
"scrollX": true
});
} );
&lt;/script&gt;
</html></pre>