Menggunakan dataTables

Assalamualaikum mas/mbak, saya mau tanya untuk penerapan plugin dataTables diphp, sperti contoh skrip dibawah, kok bisa berantakan ya?, kira-kira salahnya dimana mas/mbak, sebelumnya terimakasih banyak untuk ilmu yg di share di web sekolah koding ini.

//Fungsi_table.php

<?php
function buka_tabel($judul){
  echo '<div class="table-responsive">
    <table class="table-data table table-striped" width="100%">
    <thead>
      <tr>
        <th style="width: 10px"> No </th>';

        foreach($judul as $jdl){
          echo '<th>'.$jdl.'</th>';
        }

        '<th style="width: 60px"> Aksi </th>
      </tr>
    </thead>
  <tbody>';
}

function isi_tabel($no, $data, $link, $id, $edit=true, $hapus=true){
  echo '<td valign="top">'.$no.'</td>';

  foreach($data as $dt){
    echo '<td valign="top">'.$dt.'</td>';
  }
  echo '<td valign="top">';

  if($edit){
    echo '<a href=" '.$link.'&show=form&id='.$id.' " class="btn btn-primary btn-sm">
    <i class="glyphicon glyphicon-pencil"></i></a>';
  }

  if($hapus){
    echo '<a href=" '.$link.'&show=delete&id='.$id.' " class="btn btn-danger btn-sm">
    <i class="glyphicon glyphicon-trash"></i></a>';
  }

  echo '</td></tr>';
}

function tutup_tabel(){
  echo '</tbody> </table> </div>';
}

 ?>

//table.php

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="../plugin/dataTables/media/css/dataTables.bootstrap.css" type="text/css">
    <script type="text/javascript" src="../plugin//media/js/dataTables/bootstrap.js"></script>
    <link type="text/css" rel="stylesheet" href="../plugin/bootstrap/css/bootstrap.min.css">
    <!-- <script type="text/javascript" src="../plugin/jquery.min.js"></script> -->
    <script type="text/javascript">
      $('document').ready(function(){
        $('table').dataTable();
      });
    </script>
  </head>
  <body>
    <?php
    include "../library/function_table.php";

    buka_tabel(array("Judul"));
    isi_tabel(1, array("Judul Artikel Pertama"), "#", 1);
    isi_tabel(2, array("Judul Artikel Kedua"), "#", 2);
    isi_tabel(3, array("Judul Artikel Ketiga"), "#", 3);
    tutup_tabel();
     ?>
  </body>
</html>

avatar benjamin
@benjamin

1 Kontribusi 0 Poin

Dipost 7 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban