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">&times;</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">&times;</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>
avatar teguh3i

Ditanyakan oleh @teguh3i

1 Kontribusi 0 Poin

Login untuk menanggapi


Jawaban

Coba ganti scriptnya menjadi ini :

<?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=<?php echo $data['id']; ?>" class="btn btn-danger btn-sm" name="bhapus">
                                    	<span><i class="fas fa-trash"></i></span>
                                    </a>
									
									<!-- 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">&times;</span></button>
									      </div>  
									      <div class="modal-body">
									         <?php
									             $id=$data['id'];
									            echo "id =".$id;
									         ?>
									      </div>
									      <div class="modal-footer">
									        
									      </div>  
									    </div>
									  </div>
									</div>

                                </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">&times;</span></button>
      </div>  
      <div class="modal-body">
      
      </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>
avatar ahanafi

Dijawab oleh @ahanafi

507 Kontribusi 220 Poin

Login untuk menanggapi


Login untuk gabung berdiskusi