php - 引导表中的分页
问题描述
我在引导程序中有一个表,它有无限的条目,我想通过增加条目自动分页数增加来自动分页。
<table class="table table-hover" align="center" border="2" style="text-align:center">
<tr height="">
<td><b>S.NO</b></td>
<td><b>DESRIPTION</b></td>
<td><b>RECIEVE</b></td>
<td><b>SENT</b></td>
<td><b>AVAILABLE BALANCE</b></td>
</tr>
<?php
$i=1;
$query = mysqli_query($con , "select * from income where userid='$searchid' ORDER BY `id` DESC");
if(mysqli_num_rows($query)>0){
while($row = mysqli_fetch_array($query)){?>
<tr>
<td><b><?php echo $i++;?></b></td>
<td><?php echo $row['description'] ; ?></td>
<td><?php echo $row['received'] ; ?></td>
<td><?php echo $row['sent'] ; ?></td>
<td><?php echo $row['current_bal'] ; ?></td>
</tr>
<?php
}}else{?>
<tr>
<td colspan='5'>NO Record Found</td>
</tr>
<?php
}
?>
</table>
解决方案
Here is your solution with datatables..add your php code inside tbody tag ...
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<table id="example" table table-bordered table-striped>
<thead>
<tr>
<th><b>S.NO</b></th>
<th><b>DESRIPTION</b></th>
<th><b>RECIEVE</b></th>
<th><b>SENT</b></th>
<th><b>AVAILABLE BALANCE</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>qwerty</td>
<td>uiop</td>
<td>asdf</td>
<td>12345</td>
</tr>
<tr>
<td>1</td>
<td>qwerty</td>
<td>uiop</td>
<td>asdf</td>
<td>12345</td>
</tr>
<tr>
<td>1</td>
<td>qwerty</td>
<td>uiop</td>
<td>asdf</td>
<td>12345</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
</body>
</html>
推荐阅读
- python - 获取用户输入并循环遍历许多变量,以便将该输入与其中一个变量匹配
- regex - PowerShell / Regex - 如何将第 7 个字符后的字符串添加到文件名列表中
- excel - EXCEL / VBA - 电子表格中的函数#VALUE错误
- c - 理解时间的计算(jiffies)
- sql - 使用所有字段的 DB2 SQL 合并
- python - 使用 Python 替换击键
- excel - Asp Net Core 3.1 大数据导出 Excel 带 ClosedXML
- reactjs - 向 PWA 的 API 平台公开 Next.js 环境变量
- javascript - Apollo 客户端和过滤查询
- ios - 错误:IOS版本代码属性必须是整数并且必须设置