Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "../koneksi.php";
- $page = $_POST['page'];
- $username = $_SESSION['username'];
- $cur_page = $page;
- $page -=1;
- $per_page = 10;
- $previous_page = true;
- $next_btn = true;
- $first_btn = true;
- $last_btn = true;
- $start = $page * $per_page;
- ?>
- <table class="table table-condensed table-bordered table-hover" cellpadding="0" cellspacing="0">
- <thead>
- <tr bgcolor="#428bca">
- <th width="3%">No</th>
- <th width="3%">No.Induk</th>
- <th width="10%">Tanggal Masuk</th>
- <th width="25%">Judul Buku</th>
- <th width="12%">Pengarang</th>
- <th width="9%">Tempat Penerbit</th>
- <th width="4%">Tahun</th>
- <th width="12%">Penerbit</th>
- <th width="10%">ISBN</th>
- <th width="5%">Klasifikasi</th>
- <th width="10%" colspan="2" ><center>Aktifitas</center></th></tr>
- </thead>
- <tbody>
- <?php
- include '../koneksi.php';
- $no = $start+1;
- $query = mysqli_query($koneksi,"SELECT * FROM tbl_buku order by id_buku desc limit $start, $per_page");
- while ($data = mysqli_fetch_array($query))
- {
- ?>
- <tr>
- <td><?php echo $no++; ?></td>
- <td><?php echo $data['no_induk']; ?></td>
- <td><?php echo date("d-M-Y", strtotime($data['tanggal'])); ?></td>
- <td><?php echo $data['judul']; ?></td>
- <td><?php echo $data['pengarang']; ?></td>
- <td><?php echo $data['tempat_terbit']; ?></td>
- <td><?php echo $data['tahun']; ?></td>
- <td><?php echo $data['penerbit']; ?></td>
- <td><?php echo $data['isbn']; ?></td>
- <td><?php echo $data['klasifikasi']; ?></td>
- <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>
- <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>
- </tr>
- <?php } ?>
- </tbody>
- </table>
- <?php
- //end while
- $result_pag_num = mysqli_query($koneksi,"select count(*) as count from tbl_buku");
- $row = mysqli_fetch_array($result_pag_num);
- $count = $row['count'];
- $no_of_paginations = ceil($count/$per_page);
- if ($cur_page >= 7){
- $start_loop = $cur_page - 3;
- if($no_of_paginations > $cur_page + 3){
- $end_loop = $cur_page + 3;
- }else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6){
- $start_loop = $no_of_paginations - 6;
- $end_loop = $no_of_paginations;
- }else{
- $end_loop = $no_of_paginations;
- }
- }else{
- $start_loop = 1;
- if($no_of_paginations > 7){
- $end_loop = 7;
- }else{
- $end_loop = $no_of_paginations;
- }
- }
- $msg ="<div class='pagination'><ul>";
- //for enable first button
- if($first_btn && $cur_page > 1){
- $msg .="<li p='1' class='active'>First</li>";
- }else if($first_btn){
- $msg .= "<li p='1' class='inactive'>First</li>";
- }
- //for enabled previous button
- if($previous_page && $cur_page > 1 ){
- $pre = $cur_page - 1;
- $msg .= "<li p='$pre' class='active'>Previous</li>";
- }else if($previous_page){
- $msg .= "<li class='inactive'>Previous</li>";
- }
- for ($i = $start_loop; $i <= $end_loop; $i++){
- if ($cur_page == $i){
- $msg .= "<li p='$i' style='color:#fff; background-color:#006699' class='active'>{$i}</li>";
- }else{
- $msg .= "<li p='$i' class='active'>{$i}</li>";
- }
- }
- //for enabled next button
- if($next_btn && $cur_page < $no_of_paginations){
- $nex = $cur_page + 1;
- $msg .= "<li p='$nex' class='active'>Next</li>";
- }else if($next_btn){
- $msg .= "<li class='inactive'>Next</li>";
- }
- //for enabled end button
- if ($last_btn && $cur_page < $no_of_paginations){
- $msg .= "<li p='$no_of_paginations' class='active'>Last</li>";
- }else if($last_btn){
- $msg .= "<li p='$no_of_paginations' class='inactive'>Last</li>";
- }
- $goto = "<input type='text' class='goto' id='goto' size='1' />
- <input type='button' id='go_btn' class='go_button' value='GO' style='padding-bottom:3px' />";
- $total_string = "<span class='total' a='$no_of_paginations' style='margin-left:60px'>Page<b> ".$cur_page."</b> of <b> $no_of_paginations</b> Total Data: <b style='color:red'>".$count."</b></span>";
- $msg = $msg.$total_string."</ul></div>"; //conten pagination
- echo $msg;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement