93 lines
3.4 KiB
PHP
93 lines
3.4 KiB
PHP
<?php
|
|
$list_max_count = 5;
|
|
require_once 'config.php';
|
|
require_once FOLDER_ROOT.'/lib/Database/DbMessage.php';
|
|
use MessageBoard\Database\DbMessage;
|
|
|
|
$db = new DbMessage();
|
|
|
|
$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>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="css/general.css">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<div id="container">
|
|
<header>
|
|
<h1>留言板</h1>
|
|
</header>
|
|
<div id="main">
|
|
<div class="func-btn">
|
|
<ul>
|
|
<li><a href="edit.php" class="btn">New</a></li>
|
|
</ul>
|
|
</div>
|
|
<section>
|
|
<!-- 主表格 -->
|
|
<div class="list-info">
|
|
<ul>
|
|
<li><?php echo $page.'/'.$max_page ?></li>
|
|
</ul>
|
|
</div>
|
|
<?php
|
|
if (count($list) > 0) {
|
|
echo '
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>id</th>
|
|
<th>title</th>
|
|
<th>updated_at</th>
|
|
<th>action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
|
|
foreach ($list as $key => $item) {
|
|
echo '
|
|
<tr>
|
|
<th>'.$item['id'].'</th>
|
|
<td>'.$item['title'].'</td>
|
|
<td>'.$item['updated_at'].'</td>
|
|
<td class="table-row-func">
|
|
<ul>
|
|
<li><a href="edit.php?id='.$item['id'].'" class="btn">Edit</a></li>
|
|
<li><form action="save.php" method="post"><input type="hidden" name="id" value="'.$item['id'].'"><input type="hidden" name="delete" value="true"><input type="submit" class="btn" value="Delete"></form></li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
';
|
|
}
|
|
|
|
echo '
|
|
</tbody>
|
|
</table>
|
|
';
|
|
}
|
|
else {
|
|
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>
|
|
</div>
|
|
</body>
|
|
</html>
|