✏️ 正在编辑: pagination2.php
路径:
/home/llpreacharge/public_html/Admin/pagination2.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<html> <head> <title>Pagination</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <style> table { border-collapse: collapse; } .inline{ display: inline-block; float: right; margin: 20px 0px; } input, button{ height: 34px; } .pagination { display: inline-block; } .pagination a { font-weight:bold; font-size:18px; color: black; float: left; padding: 8px 16px; text-decoration: none; border:1px solid black; } .pagination a.active { background-color: pink; } .pagination a:hover:not(.active) { background-color: skyblue; } </style> </head> <body> <center> <?php // Import the file where we defined the connection to Database. require_once "connection.php"; //require_once "time.php"; $date="2020-07-27"; $per_page_record = 10; // Number of entries to show in a page. // Look for a GET variable page if not found default is 1. if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; } $start_from = ($page-1) * $per_page_record; $query = "SELECT *FROM recharge where Rechargedate='$date' LIMIT " . $start_from . ',' . $per_page_record; //$query = "SELECT * FROM recharge where Rechargedate='$date' LIMIT" $start_from, $per_page_record"; $rs_result = mysqli_query ($con, $query); ?> <div class="container"> <br> <div> <h1>Pagination Simple Example</h1> <p>This page demonstrates the basic Pagination using PHP and MySQL. </p> <table class="table table-striped table-condensed table-bordered"> <thead> <tr> <th width="10%">ID</th> <th>Operator</th> <th>Amount</th> <th>Status</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($rs_result)) { // Display each field of the records. ?> <tr> <td><?php echo $row["Id"]; ?></td> <td><?php echo $row["Companyname"]; ?></td> <td><?php echo $row["Amount"]; ?></td> <td><?php echo $row["Status"]; ?></td> </tr> <?php }; ?> </tbody> </table> <div class="pagination"> <?php $query = "SELECT COUNT(*) FROM recharge where Rechargedate='$date'"; $rs_result = mysqli_query($con, $query); $row = mysqli_fetch_row($rs_result); $total_records = $row[0]; echo "</br>"; // Number of pages required. $total_pages = ceil($total_records / $per_page_record); $pagLink = ""; if($page>=2){ echo "<a href='pagination2.php?page=".($page-1)."'> Prev </a>"; } for ($i=1; $i<=$total_pages; $i++) { if ($i == $page) { $pagLink .= "<a class = 'active' href='pagination2.php?page=" .$i."'>".$i." </a>"; } else { $pagLink .= "<a href='pagination2.php?page=".$i."'> ".$i." </a>"; } }; echo $pagLink; if($page<$total_pages){ echo "<a href='pagination2.php?page=".($page+1)."'> Next </a>"; } ?> </div> <div class="inline"> <input id="page" type="number" min="1" max="<?php echo $total_pages?>" placeholder="<?php echo $page."/".$total_pages; ?>" required> <button onClick="go2Page();">Go</button> </div> </div> </div> </center> <script> function go2Page() { var page = document.getElementById("page").value; page = ((page><?php echo $total_pages; ?>)?<?php echo $total_pages; ?>:((page<1)?1:page)); window.location.href = 'pagination2.php?page='+page; } </script> </body> </html>
💾 保存文件
← 返回文件管理器