Advertisement
rakahikmah

php ajax datatable

Jan 21st, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. // function datatable  
  2. function viewData(){
  3.     $(document).ready(function() {
  4.     $('.data').DataTable({
  5.         "processing": true,
  6.         "serverSide": true,
  7.         "ajax": "core/process.php",
  8.         success : function(data){
  9.             $('tbody').html(data);  
  10.           }
  11.       })
  12.     });
  13.   }
  14.  
  15. //query dengan pdo
  16.  $stmt = $db->prepare("SELECT * FROM pelanggan");
  17.   $stmt->execute();
  18.   $no = 1;
  19.   while($row = $stmt->fetch()){
  20. ?>
  21.   <tr>
  22.     <?php $result[]=$row;?>
  23.     <td><?php echo $no++;?></td>
  24.     <td><?php echo $row['id_pelanggan'];?></td>
  25.     <td><?php echo $row['nm_pelanggan'];?></td>
  26.     <td><?php echo $row['alamat'];?></td>
  27.     <td><?php echo $row['telepon'];?></td>
  28.     <td><?php echo $row['email'];?></td>
  29.     <td width="160">
  30.       <button class="btn btn-warning" data-toggle="modal" data-target="#edit-<?php echo $row['id_pelanggan']; ?>">Edit</button>
  31.       <button type="button" class="btn btn-danger" onclick="deleteData(<?php echo $row['id_pelanggan']?>)"> Delete </button>
  32.     </td>
  33.   </tr>
  34.   <?php
  35.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement