Advertisement
Guest User

php

a guest
Apr 23rd, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.91 KB | None | 0 0
  1. <?php
  2.  
  3. require 'data_koneksi.php';
  4.  
  5. $sqli = "SELECT * FROM data";
  6. $query = $conn->query($sqli);
  7. $result = $query->fetch_assoc();
  8.  
  9. $dataPerhalaman = 5;
  10. $jumlahData = count($result);
  11. $jumlahPageHalaman = ceil($jumlahData / $dataPerhalaman);
  12.  
  13. ?>
  14.  
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18.     <title>New AJAX</title>
  19.  
  20. <!-- boostrap css -->
  21. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"/>
  22.  
  23. <!-- jquery cdn -->
  24. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  25. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  26. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
  27.  
  28. <!-- sweet alert 1 -->
  29. <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  30.  
  31.  
  32.  
  33. <style type="text/css">
  34.    
  35.  #loader {
  36.  
  37.     position: fixed;
  38.     bottom: 59.8vh;
  39.     left: 73vh;
  40.     z-index: 1;
  41.     display: none;;
  42.  
  43.  }
  44.  
  45.  #loader img{
  46.  
  47.     width: 60px;
  48.     height: 60px;
  49.  }
  50.  
  51.  
  52. </style>
  53.  
  54.  
  55. </head>
  56. <body>
  57.  
  58. <div id="dataTable">
  59. <div class="row ml-5">
  60. <div class="col-lg-8">
  61. <div class="card">
  62. <div class="card-header bg-white">
  63. <h5 class="text-primary"> Data List Table <strong class="offset-lg-6"> Author:@restuvh </strong> </h5>
  64. </div>
  65. <div class="card-content">
  66. <div class="card-body">
  67. <div class="table-responsive">
  68.     <table class="table table-dark table-striped table-bordered text-center">
  69.         <thead>
  70.         <tr>
  71.             <th>Id</th>
  72.             <th>Nama</th>
  73.             <th>Gambar</th>
  74.             <th>Status</th>
  75.             <th>Perbarui</th>
  76.             <th>Hapus</th>
  77.         </tr>
  78.         </thead>
  79.         <tbody id="dataTableBody">
  80.  
  81.        
  82.         </tbody>
  83.         </table>
  84.  
  85.                 <ul class="pagination">
  86.  
  87.                 <?php for ($i = 1;  $i <= $jumlahPageHalaman; $i++) : ?>
  88.                 <?php if ($i == 1) : ?>
  89.  
  90.                 <li class="page-item">
  91.  
  92.                 <a class="page-link active" href="javascript:void(0);"
  93.                 id="page" onclick="pageData('<?php echo $i; ?>')"> <?php echo $i; ?></a>
  94.  
  95.                 </li>
  96.  
  97.                 </ul>
  98.  
  99.                 <?php endif; ?>
  100.                 <?php endfor; ?>
  101.  
  102.                             </div>
  103.                          </div>
  104.                     </div>
  105.                 </div>
  106.             </div>
  107.         </div>
  108.     </div>
  109. </div>
  110.   </body>
  111. </html>
  112.  
  113. <!-- sweet alert  -->
  114. <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  115.  
  116. <script type="text/javascript">
  117.  
  118. $(document).ready(function() {
  119.  
  120.     tampilkanData();
  121.  
  122. }); //end event updateData
  123.  
  124.  
  125. }); //end call jquery
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. // pagenation data
  133.     function pageData(){
  134.  
  135.     var dataPage = $("#page");
  136.     var tablePage = '';
  137.  
  138.     $.ajax({
  139.  
  140.         url: 'http://localhost/CRUD_AJAX_NEW/data_pagenation.php',
  141.         type: 'GET',
  142.         statusCode: {
  143.  
  144.             404: function() {
  145.  
  146.                 alert('ajax error detected');
  147.             }
  148.  
  149.         },
  150.         data: {
  151.  
  152.             'pageData': dataPage,
  153.             'pageData': tablePage
  154.         },
  155.  
  156.         success: function(data) {
  157.  
  158.             $("#dataTableBody").html(data);
  159.  
  160.             tampilkanData(data);
  161.  
  162.         },
  163.  
  164.     }); //end call ajax
  165.  
  166. }; //end event pagenation data
  167.  
  168.  
  169.  
  170. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement