【发布时间】:2020-12-02 02:27:58
【问题描述】:
<html>
<head>
<meta charset="utf-8">
<title>View Records</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div class="form">
<p>
<a href="dashboard.php">Dashboard</a>
| <a href="view.php">View Records</a>
| <a href="insert.php">Add Admin</a>
| <a href="logout.php" onclick="return confirm('Are you sure to Logout?');">Logout</a>
</p>
<table width="100%" border="1" style="border-collapse:collapse;">
<thead>
<tr>
<th><strong>ID</strong></th>
<th><strong>Username</strong></th>
<th><strong>User Password</strong></th>
<th><strong>Full Name</strong></th>
<th><strong>Edit</strong></th>
<th><strong>Delete</strong></th>
</tr>
</thead>
</body>
<?php
$count=1;
$sel_query="Select * from admin ORDER BY id ASC;";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td align="center"><?php echo $row["ID"]; ?></td>
<td align="center"><?php echo $row["username"]; ?></td>
<td align="center"><?php echo $row["user_pass"]; ?></td>
<td align="center"><?php echo $row["fullname"]; ?></td>
<td align="center">
<a href="edit.php?id=<?php echo $row["ID"];?>">Edit</a></td>
<td align="center">
<a href="delete.php?id=<?php echo $row["ID"]; ?>"onclick="return confirm('Data cannot be retrieved after deleted. Are you sure to delete?');">Delete</a></td>
</tr>
<?php $count++; } ?>
</tbody>
</table>
</div>
</body>
</html>```
【问题讨论】:
-
MVC 是一种设计模式。尝试实施它,如果遇到任何问题,请回来。
-
你应该看看 Laravel,它是一个使用 MVC 模式的 PHP 框架。
-
有几个选项取决于您想要实现的目标以及如何使用它。例如,HTML 是否需要是用户可编辑的模板?我的第一个想法是让您的 HTML 有一些占位符用于将要填充的数据。即将定义一个
,并带有某种可识别的标记供您替换为值。然后在 PHP 中你阅读 HTML 找到行模板,循环你的数据创建行的副本,然后输出。顺便说一句:你有
标签: php html model-view-controller