【发布时间】:2018-12-05 14:08:54
【问题描述】:
我想知道是否可以使用表上的按钮从数据库中删除该特定行。 这是一个例子:
<thead>
<tr>
<th>Identity</th>
<th>Name</th>
<th>Stuff</th>
<th>Action(Delete)</th>
</tr>
</thead>
<tbody>
<?php
$con=mysqli_connect("","","","");
// Check connection
if (mysqli_connect_errno())
{
echo "Error " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM sm_admins");
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['identity'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
switch ($row['level']) {
case "hello" : echo "<td>Nice Try</td>";
break;
case "bye" : echo "<td>Row in a row</td>";
break;
case "Cake" : echo "<td>Lemon</td>";
break;
case "ao" : echo "<td>Key</td>";
break;
case "as" : echo "<td>Charger</td>";
break;
echo "<td> <button class='btn btn-red btn-icon-only' onclick='deleterow(" . $row['identity'] . ")> <i class='fa fa-times'></i> </button></td>";
}
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
例如,我在数据库中有 2 行,这会在 HTML 表上创建 2 个不同的行,我想知道是否可以使用 HTML 上每一行末尾的按钮从数据库中删除特定行页面
【问题讨论】:
标签: php html mysql sql phpmyadmin