gpt4 book ai didi

php - 通过表从数据库中删除记录

转载 作者:行者123 更新时间:2023-11-29 10:15:04 25 4
gpt4 key购买 nike

我在 html 表中显示数据库中的用户,我为表中的每条记录创建一个按钮以删除该记录,但我不知道该怎么做
这是我的代码:

<table width="200" border="1">

<?php
while($row=mysqli_fetch_assoc($result)){
?><tr>
<th scope="col">ID</th>
<th scope="col">user</th>
<th scope="row">pass</th>
<th scope="col">edit</th>

</tr>


<td><?php echo $row['id']?></td>
<td><?php echo $row['user']?></td>
<td><?php echo $row['pass']?></td>
<td><a href="delone.php"><button>edit</button></a></td>
</tr>

<?php
}
?>


</table>

最佳答案

我认为您正在为每个用户提供“编辑”选项。如果你想添加删除选项,即:用户的“id,user,pass”将被删除。为此,只需在下面添加编辑选项即可。

<td><a href="delete.php?id=<?php echo $row['id'] ?>" >Delete </a></td>

现在,使用 SQL 查询,您可以从数据库中删除该信息。

if (isset($_GET['id'])) {

// write query to delete from db
}

现在记录将从您的数据库中删除。认真做吧!快乐编码!!!

关于php - 通过表从数据库中删除记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50237244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com