【发布时间】:2018-04-02 18:28:22
【问题描述】:
所以我希望能够使用表格中每一行旁边的按钮删除 PHP 中的记录。我在任何地方都找不到可以帮助我解决问题的好教程,而且我真的被困住了,不知道该怎么办。
如果有人可以告诉我该怎么做,这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>PCSS Grad Gown</title>
<link rel="stylesheet" type="text/css" href="Grad_Gown_Report.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
<style>
body {
background-image: url("http://www.miguelmontalban.com/wp-content/uploads/2015/11/uSr9bZA-fancy-background-images.jpg");
}
td {
color: white;
}
.Grad_Table {
color :white;
}
</style>
</head>
<body>
<?php
$servername = "Private";
$username = "Private";
$password = "Private";
$dbname = "Private";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
$order;
}
$order = $_GET['order'];
if (!$order) {
$order = "name";
}
$sql = mysqli_query ($conn, "SELECT * FROM Information ORDER By $order");
?>
<div class="table-responsive" id="grad_table">
<br>
<br>
<table class="Grad_Table" width="100%" border="12px">
<thead>
<tr>
<td><a href="Grad_Gown_Report.php">Name:</a></td>
<td><a href="Grad_Gown_Report_2.php">Student #:</a></td>
<td>Homeform #:</td>
<td>Unit:</td>
<td>Height:</td>
<td>Size:</td>
<td></td>
</tr>
</thead>
<tbody>
<?php
while ($rows = mysqli_fetch_assoc($sql)) {
?>
<tr>
<td><?php echo $rows['Name'];?></td>
<td><?php echo $rows['Studentnum'];?></td>
<td><?php echo $rows['Homeform'];?></td>
<td><?php echo $rows['Unit'];?></td>
<td><?php echo $rows['Height'];?></td>
<td><?php echo $rows['Size'];?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</body>
</html>
我可以完美地从数据库中检索数据,其他一切都完全按照我的意愿运行。我唯一需要的是删除功能。我尝试了很多东西,包括 W3 Schools 的教程,我尝试了面向对象和过程方法,但它们都给了我同样的错误。我真的更喜欢单独的 delete.php 文件,但我对任何可行的东西都很好。
【问题讨论】:
标签: php mysql sql database html-table