我想知道是否有可能通过表上的一个按钮从数据库中删除指定的行。下面是一个示例:
<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);
?>例如,我在数据库中有两行,这在HTML表上创建了两个不同的行,我想知道是否可以使用HTML页面上每行末尾的按钮从数据库中删除指定的行
https://stackoverflow.com/questions/51049907
复制相似问题