Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
您需要将要删除的记录的 ID 添加到删除 url,例如:
然后,在您的 delete.php 脚本中,您需要执行以下操作:
当然,这不是完整的脚本,但向您展示了基本知识需要完成。在查询中使用传入的值时要小心 - 不想让 SQL 注入漏洞毁了您的一天。
但是,请注意,对此类事情使用“GET”类型查询通常是一个坏主意。如果此页面被 Google 抓取(仅此而已),您会发现简单的抓取行为就毁掉了您的所有记录。
You need to add the ID of the record you want to delete to the delete url, e.g.:
Then, in your delete.php script, you'd do:
Of course, that's not a full script, but shows you the basics of what needs to be done. Be careful with using the passed-in value in your query - don't want to let an SQL injection hole ruin your day.
However, be aware that using a 'GET' type query for this sort of thing is generally a bad idea. If this page gets spidered by Google (for one), you'll find that the simple act of spidering has nuked ALL of your records.
您需要将行的 ID 作为参数传递给 delete.php 脚本
You need to pass the ID of the row as paramter to the delete.php script
您可以使用当前行的id并将其发送到delete.php:
然后在delete.php中通过
$deleteId = $_GET['id']
获取id并使用它...you can use the id of the current row and send it to delete.php:
then in delete.php get the id by
$deleteId = $_GET['id']
and use it...尝试将 URL 更改为
echo ''
顺便说一句 - 这不是一个好主意使用root!
Try changine the URL to something like
echo '<a href="delete.php?ID=' . $row['ID'] . '">'
BTW - Not a good idea to use root!