PHP/HTML添加一个删除按钮 [英] PHP/HTML Add A remove button
本文介绍了PHP/HTML添加一个删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我具有下面的代码,用于从用户名列与基本目录名称匹配的数据库中检索行:
I have the code below to retrieve rows from a database where the username column matches the base directory name:
$username = basename(dirname(__FILE__));
$username = mysql_real_escape_string($username);
$result = mysql_query("SELECT link, notes FROM links WHERE username='" . $username . "';");
$html .= "<ul><center><p>";
while ($row = mysql_fetch_array($result)) { //loop
extract($row);
$html .= "<li><span style=\"font-family: verdana;\"><a href=\"{$link}\" target=\"_blank\">{$link}</a></span> <span style=\"color:white; font-family: verdana;\">- {$notes}</span></li>";
}
$html .= "</ul></center></p>";
echo $html; //display results...
我如何在显示的每个html行旁边添加一个删除按钮,以从表中删除该行?
How would I add a remove button next to each html row that is displayed to delete that row from the table?
这是显示链接和文本的部分,此后我需要一个删除按钮:
This is the part where it displays the link and text and I need a remove button after that:
$html .= "<li><span style=\"font-family: verdana;\"><a href=\"{$link}\" target=\"_blank\">{$link}</a></span> <span style=\"color:white; font-family: verdana;\">- {$notes}</span></li>";
感谢您的帮助:)
推荐答案
echo "<a href='deletepage.php?id=$someid'>X</a>";
创建一个带有_GET['id']
参数的页面;
create a page that with _GET['id']
parameter;
在该页面上,即deletepage.php?id=15
$sql = "DELETE table FROM table WHERE id = ".(int)$_GET['id']
mysql_query($sql);
header("location: previoudpage.php");
这篇关于PHP/HTML添加一个删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文