Advertisement
Guest User

konsumen

a guest
Feb 11th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. <?php
  2. include"../inc/koneksi.php";
  3. ?>
  4. <table class="table table-striped table-bordered">
  5. <tr bgcolor="cccccc">
  6. <th><center>No.</center></th>
  7. <th><center>ID kategori</center></th>
  8. <th><center>Nama kategori</center></th>
  9. <th><center>Proses</center></th>
  10. </tr>
  11.  
  12.  
  13. <?php
  14. include"../inc/koneksi.php";
  15. $query = mysql_query("SELECT * FROM kategori ORDER BY id_kategori DESC") or die(mysql_error());
  16. if(mysql_num_rows($query)==0){
  17. echo'<tr><td colspan="6">Tidak ada Data!</td></tr>';
  18. }else{
  19. //pagination
  20. $per_page = 4;
  21.  
  22. $page_query = mysql_query("SELECT COUNT(*) FROM kategori");
  23. $pages = ceil(mysql_result($page_query, 0) / $per_page);
  24.  
  25. $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
  26. $start = ($page - 1) * $per_page;
  27.  
  28. $query = mysql_query("SELECT * FROM kategori LIMIT $start, $per_page");
  29. {
  30.  
  31. $no=1;
  32. while($data = mysql_fetch_assoc($query)){
  33.  
  34. echo '<tr>';
  35. echo'<td><center>'.$no.'</center></td>';
  36. echo'<td><center>'.$data['id_kategori'].'</center></td>';
  37. echo'<td><center>'.$data['nama_kategori'].'</center></td>';
  38. echo'<td><center><a class="glyphicon glyphicon-pencil" href="kategori_edit.php?id='.$data['id_kategori'].'"></a> | <a class="glyphicon glyphicon-trash" href="kategori_hapus.php?id='.$data['id_kategori'].'" onclick="return confirm(\'Yakin?\')"></a></td>';
  39. echo '<tr>';
  40.  
  41. $no++;
  42. }
  43. }
  44. ?>
  45. </table>
  46. <!--Button Tambah Data-->
  47. <div class="container">
  48. <form class="form-horizontal" role"form" action="kategori_tambah.php" method="POST">
  49. <button type="submit" class="btn btn-primery"><span class="glyphicon glyphicon-plus"></span> Tambah Data</button>
  50. </form>
  51. </div>
  52. <!--pagination-->
  53. <?php } ?>
  54. <!--pagination-->
  55. <hr>
  56. <center>
  57. <ul class="pagination pagination-sm">
  58. <?php
  59. if($pages >= 1 && $page <= $pages)
  60. {
  61. for($x=1; $x<=$pages; $x++)
  62. {
  63. //echo ($x == $page) ? '<b><a href="?page='.$x.'">'.$x.'</a></b> ' : '<a href="?page='.$x.'">'.$x.'</a> ';
  64. if($x == $page)
  65. echo ' <li class="active"><a href="?page='.$x.'">'.$x.'</a></li>';
  66. else
  67. echo ' <li><a href="?page='.$x.'">'.$x.'</a></li>';
  68. }
  69. }
  70. ?>
  71. </ul>
  72. </center>
  73. <!--pagination-->
  74.  
  75. </div>
  76. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement