如何在 PHP 中测试特定链接是否被点击
我已经搜索这个问题的答案好几天了,我真的需要一个答案。 所以..我有一个数据库和一个从数据库获取数据的脚本:
while ($row = mysql_fetch_array ($query))
{
$name = $row['name'];
$email = $row['email'];
$tut_title = $row['tut_title'];
$URL = $row['URL'];
$description = $row ['description'];
$Status = $row['Status'];
echo "<tr>....<form action="samepage.php"><input type="submit"></form>
....
当单击提交表单时,正在加载同一页面并出现 if(isset $POST['submit']) 指令。 发生此操作时,我需要从数据库中删除该特定记录。 (仅存储最后一个条目的数据)
所以我需要在那段时间内的某个地方存储该特定记录的数据,这样我就可以用它来删除..我不知道你是否可以从头到尾我的请求,但我会回答你的任何问题,因为我真的不知道如何更好地解释它。
提前非常感谢你们。
I ve searched the answer to this question for days and I really need an answer..
so.. I have a database and a script that fetches the data from the database:
while ($row = mysql_fetch_array ($query))
{
$name = $row['name'];
$email = $row['email'];
$tut_title = $row['tut_title'];
$URL = $row['URL'];
$description = $row ['description'];
$Status = $row['Status'];
echo "<tr>....<form action="samepage.php"><input type="submit"></form>
....
When clicked the submit form, same page is being loaded and an if(isset $POST['submit']) instruction comes up.
When this action occurs, I need to delete that specific record from the database.
(only data for the last entry will be stored)
So I need to store the data for that specific record somewhere inside that while, so I can use it to delete.. I don't know if you can make heads and tails out of my request but I will answer to any of your questions because I really don't know how to explain it better.
Thank you so much in advance guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该记录应该有一个 AUTO_INCRMENT 主键 - 我们称之为
$id
。您将该标识符添加到表单中:
如前所述,您使用
isset()
检查是否使用了提交按钮。您可以使用$_GET['id']
获取标识符并构建DELETE
查询。The record should have an AUTO_INCREMENT primary key - let's call it
$id
.You add that identifier to the form:
You, as already said, check for the submit button being used using
isset()
. You there can fetch the identifier using$_GET['id']
and construct aDELETE
query.如果您有一个数据库并且您已经搜索并显示了一些值,并且当我单击与此元素关联的超链接时您想要删除一些特定值,那么可以使用此代码。
喜欢 :
Lets if you have a data base and you have searched out and display some value and You want to delete some specific value when i clicked on hyper link associated with this element then use this code.
like :