Advertisement
dotphp

load_buku

Dec 17th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.25 KB | None | 0 0
  1. <?php
  2. include "../koneksi.php";
  3.  
  4. $page = $_POST['page'];
  5. $username = $_SESSION['username'];
  6. $cur_page  = $page;
  7. $page -=1;
  8. $per_page = 10;
  9. $previous_page = true;
  10. $next_btn = true;
  11. $first_btn = true;
  12. $last_btn = true;
  13. $start = $page * $per_page;
  14.  
  15. ?>
  16. <table class="table table-condensed table-bordered table-hover" cellpadding="0" cellspacing="0">
  17. <thead>
  18.   <tr bgcolor="#428bca">
  19.       <th width="3%">No</th>
  20.       <th width="3%">No.Induk</th>
  21.       <th width="10%">Tanggal Masuk</th>
  22.       <th width="25%">Judul Buku</th>
  23.       <th width="12%">Pengarang</th>
  24.       <th width="9%">Tempat Penerbit</th>
  25.       <th width="4%">Tahun</th>
  26.       <th width="12%">Penerbit</th>
  27.       <th width="10%">ISBN</th>
  28.       <th width="5%">Klasifikasi</th>
  29.       <th width="10%" colspan="2" ><center>Aktifitas</center></th></tr>
  30. </thead>
  31. <tbody>
  32.       <?php
  33.       include '../koneksi.php';
  34.       $no = $start+1;
  35.       $query = mysqli_query($koneksi,"SELECT * FROM tbl_buku order by id_buku desc limit $start, $per_page");
  36.       while ($data = mysqli_fetch_array($query))
  37.       {
  38.       ?>
  39.   <tr>
  40.       <td><?php echo $no++; ?></td>
  41.       <td><?php echo $data['no_induk']; ?></td>
  42.       <td><?php echo date("d-M-Y", strtotime($data['tanggal'])); ?></td>
  43.       <td><?php echo $data['judul']; ?></td>
  44.       <td><?php echo $data['pengarang']; ?></td>
  45.       <td><?php echo $data['tempat_terbit']; ?></td>
  46.       <td><?php echo $data['tahun']; ?></td>
  47.       <td><?php echo $data['penerbit']; ?></td>
  48.       <td><?php echo $data['isbn']; ?></td>
  49.       <td><?php echo $data['klasifikasi']; ?></td>
  50.       <td align="center"><a href="buku_masuk_edit.php?id_buku=<?php echo $data['id_buku'];?>"><img src="../images/Edit-32.png">Edit</a></span></td>
  51.       <td align="center"><a href="buku_masuk_delete.php?id_buku=<?php echo $data['id_buku'];?>" onClick="return confirm('Apakah Anda Yakin Akan Menghapus Data Buku Ini ?')"><img src="../images/Delete-32.png">Hapus</a></td>
  52.       </tr>
  53.     <?php } ?>
  54.                        
  55. </tbody>
  56. </table>                   
  57.  
  58. <?php
  59. //end while
  60. $result_pag_num = mysqli_query($koneksi,"select count(*) as count from tbl_buku");
  61. $row = mysqli_fetch_array($result_pag_num);
  62.  
  63. $count = $row['count'];
  64.  
  65. $no_of_paginations = ceil($count/$per_page);
  66.  
  67. if ($cur_page >= 7){
  68.     $start_loop = $cur_page - 3;
  69.     if($no_of_paginations > $cur_page + 3){
  70.         $end_loop = $cur_page + 3;
  71.     }else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6){
  72.         $start_loop = $no_of_paginations - 6;
  73.         $end_loop = $no_of_paginations;
  74.     }else{
  75.         $end_loop = $no_of_paginations;
  76.     }
  77.  
  78. }else{
  79.     $start_loop = 1;
  80.     if($no_of_paginations > 7){
  81.         $end_loop = 7;
  82.     }else{
  83.         $end_loop = $no_of_paginations;
  84.     }
  85. }
  86.  
  87. $msg ="<div class='pagination'><ul>";
  88. //for enable first button
  89. if($first_btn && $cur_page > 1){
  90.     $msg .="<li p='1' class='active'>First</li>";  
  91. }else if($first_btn){
  92.     $msg .= "<li p='1' class='inactive'>First</li>";   
  93. }
  94.  
  95. //for enabled previous button
  96. if($previous_page && $cur_page > 1 ){
  97.     $pre = $cur_page - 1;
  98.     $msg .= "<li p='$pre' class='active'>Previous</li>";   
  99. }else if($previous_page){
  100.     $msg .= "<li class='inactive'>Previous</li>";  
  101. }
  102.  
  103. for ($i = $start_loop; $i <= $end_loop; $i++){
  104.     if ($cur_page == $i){
  105.         $msg .= "<li p='$i' style='color:#fff; background-color:#006699' class='active'>{$i}</li>";
  106.     }else{
  107.         $msg .= "<li p='$i' class='active'>{$i}</li>"; 
  108.     }
  109. }
  110. //for enabled next button
  111. if($next_btn && $cur_page < $no_of_paginations){
  112.     $nex = $cur_page + 1;
  113.     $msg .= "<li p='$nex' class='active'>Next</li>";
  114. }else if($next_btn){
  115.     $msg .= "<li class='inactive'>Next</li>";  
  116. }
  117. //for enabled end button
  118. if ($last_btn && $cur_page < $no_of_paginations){
  119.     $msg .= "<li p='$no_of_paginations' class='active'>Last</li>"; 
  120. }else if($last_btn){
  121.     $msg .= "<li p='$no_of_paginations' class='inactive'>Last</li>";   
  122. }
  123.  
  124. $goto = "<input type='text' class='goto' id='goto' size='1' />
  125. <input type='button' id='go_btn' class='go_button' value='GO' style='padding-bottom:3px' />";
  126. $total_string = "<span class='total' a='$no_of_paginations' style='margin-left:60px'>Page<b> ".$cur_page."</b> of <b> $no_of_paginations</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Data: <b style='color:red'>".$count."</b></span>";
  127. $msg = $msg.$total_string."</ul></div>"; //conten pagination
  128.  
  129. echo $msg;
  130.  
  131. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement