Advertisement
Mista

Untitled

Aug 18th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.43 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['cari'])) {
  3. $cari = $_POST['cari'];
  4. } else {
  5. $cari = "";
  6. }
  7. ?>
  8. <!---<link href="../../assets/css/bootstrap.min.css" rel="stylesheet">--->
  9. <div class="row">
  10. <div class="col-md-12">
  11. <div class="page-header">
  12. <h4>
  13. <i class="glyphicon glyphicon-road"></i> Data Kendaran
  14.  
  15. <div class="pull-right btn-tambah">
  16. <form class="form-inline" method="POST" action="index.php">
  17. <div class="form-group">
  18. <div class="input-group">
  19. <div class="input-group-addon">
  20. <i class="glyphicon glyphicon-search"></i>
  21. </div>
  22. <input type="text" class="form-control" name="cari" placeholder="Cari ..." autocomplete="off" value="<?php echo $cari; ?>">
  23. </div>
  24. </div>
  25. <a class="btn btn-info" href="?page=tambah">
  26. <i class="glyphicon glyphicon-plus"></i> Tambah
  27. </a>
  28. </form>
  29. </div>
  30.  
  31. </h4>
  32. </div>
  33.  
  34. <?php
  35. if (empty($_GET['alert'])) {
  36. echo "";
  37. } elseif ($_GET['alert'] == 1) {
  38. echo "<div class='alert alert-danger alert-dismissible' role='alert'>
  39. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  40. <span aria-hidden='true'>&times;</span>
  41. </button>
  42. <strong><i class='glyphicon glyphicon-alert'></i> Gagal!</strong> Terjadi kesalahan.
  43. </div>";
  44. } elseif ($_GET['alert'] == 2) {
  45. echo "<div class='alert alert-success alert-dismissible' role='alert'>
  46. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  47. <span aria-hidden='true'>&times;</span>
  48. </button>
  49. <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Kendaraan berhasil disimpan.
  50. </div>";
  51. } elseif ($_GET['alert'] == 3) {
  52. echo "<div class='alert alert-success alert-dismissible' role='alert'>
  53. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  54. <span aria-hidden='true'>&times;</span>
  55. </button>
  56. <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Kendaraan berhasil diubah.
  57. </div>";
  58. } elseif ($_GET['alert'] == 4) {
  59. echo "<div class='alert alert-success alert-dismissible' role='alert'>
  60. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  61. <span aria-hidden='true'>&times;</span>
  62. </button>
  63. <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Kendaraan berhasil dihapus.
  64. </div>";
  65. }
  66. ?>
  67.  
  68. <div class="panel panel-default">
  69. <div class="panel-heading">
  70. <h3 class="panel-title">Data Kendaraan</h3>
  71. </div>
  72. <div class="panel-body">
  73. <div class="table-responsive">
  74. <table class="table table-striped table-hover">
  75. <thead>
  76. <tr>
  77. <th>No.</th>
  78. <th>Kendaran</th>
  79. <th>Tipe Kendaran</th>
  80. <th>Nomor Polisi</th>
  81. <th>Keterangan</th>
  82. <th>Aksi</th>
  83. </tr>
  84. </thead>
  85.  
  86. <tbody>
  87. <?php
  88. /* Pagination */
  89. $batas = 5;
  90.  
  91. if (isset($cari)) {
  92. $jumlah_record = mysqli_query($db, "SELECT * FROM trasportasi
  93. WHERE nopol LIKE '%$cari%' OR ket LIKE '%$cari%'")
  94. or die('Ada kesalahan pada query jumlah_record: '.mysqli_error($db));
  95. } else {
  96. $jumlah_record = mysqli_query($db, "SELECT * FROM trasportasi")
  97. or die('Ada kesalahan pada query jumlah_record: '.mysqli_error($db));
  98. }
  99.  
  100. $jumlah = mysqli_num_rows($jumlah_record);
  101. $halaman = ceil($jumlah / $batas);
  102. $page = (isset($_GET['hal'])) ? (int)$_GET['hal'] : 1;
  103. $mulai = ($page - 1) * $batas;
  104. /*-------------------------------------------------------------------*/
  105. $no = 1;
  106. if (isset($cari)) {
  107. $query = mysqli_query($db, "SELECT * FROM trasportasi
  108. WHERE nopol LIKE '%$cari%' OR ket LIKE '%$cari%'
  109. ORDER BY nopol DESC LIMIT $mulai, $batas")
  110. or die('Ada kesalahan pada query Kendaraan: '.mysqli_error($db));
  111. } else {
  112. $query = mysqli_query($db, "SELECT * FROM trasportasi
  113. ORDER BY nopol DESC LIMIT $mulai, $batas")
  114. or die('Ada kesalahan pada query Kendaraan: '.mysqli_error($db));
  115. }
  116.  
  117. while ($data = mysqli_fetch_assoc($query)) {
  118. echo " <tr>
  119. <td width='50' class='center'>$no</td>
  120. <td width='60'>$data[jenis]</td>
  121. <td width='150'>$data[tipe]</td>
  122. <td width='180'>$data[nopol]</td>
  123. <td width='120'>$data[ket]</td>
  124. <td width='100'>
  125. <div class=''>
  126. <a data-toggle='tooltip' data-placement='top' title='Ubah' style='margin-right:5px' class='btn btn-info btn-sm' href='?page=ubah&id=$data[nopol]'>
  127. <i class='glyphicon glyphicon-edit'></i>
  128. </a>";
  129. ?>
  130. <a data-toggle="tooltip" data-placement="top" title="Hapus" class="btn btn-danger btn-sm" href="proses-hapus.php?id=<?php echo $data['nopol'];?>" onclick="return confirm('Anda yakin ingin menghapus Kendaraan <?php echo $data['ket']; ?>?');">
  131. <i class="glyphicon glyphicon-trash"></i>
  132. </a>
  133. <?php
  134. echo "
  135. </div>
  136. </td>
  137. </tr>";
  138. $no++;
  139. }
  140. ?>
  141. </tbody>
  142. </table>
  143. <?php
  144. if (empty($_GET['hal'])) {
  145. $halaman_aktif = '1';
  146. } else {
  147. $halaman_aktif = $_GET['hal'];
  148. }
  149. ?>
  150.  
  151. <a>
  152. Halaman <?php echo $halaman_aktif; ?> dari <?php echo $halaman; ?> |
  153. Total <?php echo $jumlah; ?> data
  154. </a>
  155.  
  156. <nav>
  157. <ul class="pagination pull-right">
  158. <!-- Button untuk halaman sebelumnya -->
  159. <?php
  160. if ($halaman_aktif<='1') { ?>
  161. <li class="disabled">
  162. <a href="" aria-label="Previous">
  163. <span aria-hidden="true">&laquo;</span>
  164. </a>
  165. </li>
  166. <?php
  167. } else { ?>
  168. <li>
  169. <a href="" aria-label="Previous">
  170. <span aria-hidden="true">&laquo;</span>
  171. </a>
  172. </li>
  173. <?php
  174. }
  175. ?>
  176.  
  177. <!-- Link halaman 1 2 3 ... -->
  178. <?php
  179. for($x=1; $x<=$halaman; $x++) { ?>
  180. <li class="">
  181. <a href=""><?php echo $x ?></a>
  182. </li>
  183. <?php
  184. }
  185. ?>
  186.  
  187. <!-- Button untuk halaman selanjutnya -->
  188. <?php
  189. if ($halaman_aktif>=$halaman) { ?>
  190. <li class="disabled">
  191. <a href="" aria-label="Next">
  192. <span aria-hidden="true">&raquo;</span>
  193. </a>
  194. </li>
  195. <?php
  196. } else { ?>
  197. <li>
  198. <a href="" aria-label="Next">
  199. <span aria-hidden="true">&raquo;</span>
  200. </a>
  201. </li>
  202. <?php
  203. }
  204. ?>
  205. </ul>
  206. </nav>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement