分頁功能
This commit is contained in:
parent
55f10909b4
commit
11b00e484b
@ -1,24 +1,15 @@
|
||||
<?php
|
||||
|
||||
$list_max_count = 5;
|
||||
require_once 'config.php';
|
||||
require_once FOLDER_ROOT.'/lib/Database/DbMessage.php';
|
||||
use MessageBoard\Database\DbMessage;
|
||||
|
||||
$db = new DbMessage();
|
||||
$list = $db->getList();
|
||||
// $list = [
|
||||
// [
|
||||
// 'id' => 1,
|
||||
// 'title' => 'text',
|
||||
// 'updated_at' => '2020-04-01 12:13',
|
||||
// ],
|
||||
// [
|
||||
// 'id' => 2,
|
||||
// 'title' => 'text',
|
||||
// 'updated_at' => '2020-04-01 12:13',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
$page = !empty($_GET["p"])?$_GET["p"]:1;
|
||||
$max_count = $db->getCount();
|
||||
$max_page = ceil($max_count/$list_max_count);
|
||||
$list = $db->getList($page, $list_max_count);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@ -40,6 +31,11 @@ $list = $db->getList();
|
||||
</div>
|
||||
<section>
|
||||
<!-- 主表格 -->
|
||||
<div class="list-info">
|
||||
<ul>
|
||||
<li><?php echo $page.'/'.$max_page ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
if (count($list) > 0) {
|
||||
echo '
|
||||
@ -80,6 +76,14 @@ $list = $db->getList();
|
||||
echo '無資料';
|
||||
}
|
||||
?>
|
||||
<div class="table-func">
|
||||
<ul>
|
||||
<li><a href="<?php echo $_SERVER['SCRIPT_NAME'].'?p='.'1'; ?>">|<</a></li>
|
||||
<li><a href="<?php echo $_SERVER['SCRIPT_NAME'].'?p='.(($page-1)>0?($page-1):1); ?>"><</a></li>
|
||||
<li><a href="<?php echo $_SERVER['SCRIPT_NAME'].'?p='.(($page+1)<$max_page?($page+1):$max_page); ?>">></a></li>
|
||||
<li><a href="<?php echo $_SERVER['SCRIPT_NAME'].'?p='.$max_page; ?>">>|</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user