86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
<?php
|
|
|
|
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',
|
|
// ],
|
|
// ];
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<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>
|
|
<!-- 主表格 -->
|
|
<?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>
|
|
<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 '無資料';
|
|
}
|
|
?>
|
|
</section>
|
|
</div>
|
|
</body>
|
|
</html>
|