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
@teguh3i

1 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

<div>Coba ganti scriptnya menjadi ini :<br><br></div><pre>&lt;?php include "koneksi.php"; ?&gt; &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;!-- Required meta tags --&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no"&gt;

&amp;lt;title&amp;gt;Data Anggota Koperasi&amp;lt;/title&amp;gt;
&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;assets/css/bootstrap.css&quot;&amp;gt;
&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;assets/datatables/DataTables-1.10.21/css/jquery.dataTables.min.css&quot;&amp;gt;
&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;assets/fontawesome/css/all.min.css&quot;&amp;gt;
&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;assets/datatables/buttons-1.6.3/css/buttons.dataTables.min.css&quot;&amp;gt;

&lt;/head&gt; &lt;body&gt;

&lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="col-sm-12"&gt; &lt;h3 align="center"&gt;ANGGOTA KOPERASI M3&lt;/h3&gt; &lt;table id="anggota" class="table table-striped table-hover table-bordered display-wrap" style="width:100%"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;No&lt;/th&gt; &lt;th&gt;Nik&lt;/th&gt; &lt;th&gt;Nama&lt;/th&gt; &lt;th&gt;Alamat Tinggal&lt;/th&gt; &lt;th&gt;Tgl.Lahir&lt;/th&gt; &lt;th&gt;Divisi&lt;/th&gt; &lt;th&gt;No Hp.&lt;/th&gt; &lt;th&gt;Tgl Aktifasi&lt;/th&gt; &lt;th&gt;Non Aktif&lt;/th&gt; &lt;th&gt;Photo Profil&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt; &lt;th&gt;Tindakan&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody class="table"&gt; &lt;?php $tampil = mysqli_query($koneksi,"select * from profilanggota"); $nomor=1; while ($data= mysqli_fetch_assoc($tampil)) { ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $nomor++;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['nik'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['nama'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['alamat'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo date('d F y',strtotime($data['tgl_lahir']));?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['divisi'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['no_hp'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo date('d F y',strtotime($data['tgl_masuk']));?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo date('d F y',strtotime($data['tgl_lahir']));?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['id'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data['status'];?&gt;&lt;/td&gt; &lt;td&gt;

                                &amp;lt;button  type=&quot;button&quot; class=&quot;btn btn-info btn-sm&quot; data-toggle=&quot;modal&quot; data-target=&quot;#editanggota&amp;lt;?php echo $data[&#039;id&#039;];?&amp;gt;&quot;&amp;gt;
                                	&amp;lt;span&amp;gt;&amp;lt;i class=&quot;fas fas fa-edit&quot;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/span&amp;gt;
                                &amp;lt;/button&amp;gt;
                                
                                &amp;lt;a href=&quot;#profilanggota?hal=hapus&amp;amp;id=&amp;lt;?php echo $data[&#039;id&#039;]; ?&amp;gt;&quot; class=&quot;btn btn-danger btn-sm&quot; name=&quot;bhapus&quot;&amp;gt;
                                	&amp;lt;span&amp;gt;&amp;lt;i class=&quot;fas fa-trash&quot;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/span&amp;gt;
                                &amp;lt;/a&amp;gt;
								
								&amp;lt;!-- MODAL EDIT --&amp;gt;

								&amp;lt;div class=&quot;modal fade&quot; id=&quot;editanggota&amp;lt;?php echo $data[&#039;id&#039;];?&amp;gt;&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot;&amp;gt;
								  &amp;lt;div class=&quot;modal-dialog&quot;&amp;gt;
								    &amp;lt;div class=&quot;modal-content&quot;&amp;gt;
								      &amp;lt;div class=&quot;modal-header shadow p-2 mb-2 bg-secondary rounded&quot;&amp;gt;
								            &amp;lt;h5 class=&quot;modal-title text-green&quot;&amp;gt;Bio Data Anggota 
								            &amp;lt;span class=&quot;badge badge-warning text-danger&quot;&amp;gt;Update&amp;lt;/span&amp;gt;&amp;lt;/h5&amp;gt;
								            &amp;lt;button type=&quot;button&quot; class=&quot;close text-danger&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&amp;gt;
								            &amp;lt;span aria-hidden=&quot;true&quot;&amp;gt;&amp;amp;times;&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;
								      &amp;lt;/div&amp;gt;  
								      &amp;lt;div class=&quot;modal-body&quot;&amp;gt;
								         &amp;lt;?php
								             $id=$data[&#039;id&#039;];
								            echo &quot;id =&quot;.$id;
								         ?&amp;gt;
								      &amp;lt;/div&amp;gt;
								      &amp;lt;div class=&quot;modal-footer&quot;&amp;gt;
								        
								      &amp;lt;/div&amp;gt;  
								    &amp;lt;/div&amp;gt;
								  &amp;lt;/div&amp;gt;
								&amp;lt;/div&amp;gt;

                            &amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                
                &amp;lt;?php  } ?&amp;gt;
                
            &amp;lt;/tbody&amp;gt;
        &amp;lt;/table&amp;gt;
         &amp;lt;button type=&quot;button&quot; class=&quot;btn btn-success&quot; data-toggle=&quot;modal&quot; data-target=&quot;#tambahanggota&quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;i class=&quot;fas fa-user-plus&quot;&amp;gt;&amp;lt;/i&amp;gt;Tambah&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;                            
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&lt;!-- MODAL TAMBAH --&gt;

&lt;div class="modal fade" id="tambahanggota" tabindex="-1"&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;New&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;

  &amp;lt;/div&amp;gt;
  &amp;lt;div class=&quot;modal-footer&quot;&amp;gt;
    
  &amp;lt;/div&amp;gt;  
&amp;lt;/div&amp;gt;

&lt;/div&gt; &lt;/div&gt;

&lt;/div&gt;

&lt;script src="assets/jquery/3.5.1/jquery.js"&gt;&lt;/script&gt; &lt;script src="assets/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script src="assets/datatables/DataTables-1.10.21/js/jquery.dataTables.min.js"&gt;&lt;/script&gt; &lt;script src="assets/fontawesome/js/all.min.js"&gt;&lt;/script&gt;
&lt;script src="assets/datatables/buttons-1.6.3/js/dataTables.buttons.min.js"&gt;&lt;/script&gt; &lt;script src="assets/datatables/buttons-1.6.3/js/buttons.flash.min.js"&gt;&lt;/script&gt; &lt;script src="assets/datatables/buttons-1.6.3/js/buttons.html5.min.js"&gt;&lt;/script&gt; &lt;script src="assets/datatables/buttons-1.6.3/js/buttons.print.min.js"&gt;&lt;/script&gt;

&lt;!-- &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"&gt;&lt;/script&gt;
&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"&gt;&lt;/script&gt; --&gt; &lt;/body&gt;

&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
    $(document).ready(function() {
        $(&#039;#anggota&#039;).DataTable({
            
            dom: &#039;Bfrtip&#039;,
            &quot;language&quot;: {
                &quot;url&quot;: &quot;//cdn.datatables.net/plug-ins/1.10.19/i18n/Indonesian.json&quot;
            },
            buttons: [
                &#039;copy&#039;, &#039;csv&#039;, &#039;excel&#039;, &#039;pdf&#039;, &#039;print&#039;
            ],
            &quot;scrollY&quot;: 300,
            &quot;scrollX&quot;: true
        });
    } );
&amp;lt;/script&amp;gt;

&lt;/html&gt;</pre>

avatar ahanafi
@ahanafi

815 Kontribusi 554 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban