I have this code that is displayed in a jquery dialog .load()'ed from a php script
我有这个代码显示在jquery对话框.load()'从PHP脚本编辑
$sql = '
SELECT
*
FROM
table
WHERE
id="'.$id.'"
';
$query = mysql_query($sql);
while($rows = mysql_fetch_array($query)) {
echo "Category: <input type='text' name='category[]' value=".$rows['category']." />";
}
this is part of a form that is posted to an external script to insert/update the db. The problem im having is how can I delete that column onclick by adding an a href "delete" after the input to be echoed, effectively deleting it from the db?
这是发布到外部脚本以插入/更新数据库的表单的一部分。我遇到的问题是如何通过在要回显的输入之后添加一个href“delete”来删除该列onclick,从而有效地从db中删除它?
1 个解决方案
#1
0
while($rows = mysql_fetch_array($query)) {
echo "Category: <input type='text' name='category[]' value=".$rows['category']." />";
echo "<a href="UrlWhereCodeOfDleteToBEWrite?task=delete&cat=".$rows['category'].">Delete</a>";
}
In file the above link will redirect write as
在文件中,上面的链接将重定向写为
if(isset($_GET['task']) && $_GET['task'] == 'delete'){
if(!isset($_GET['cat'])){
die('Invalid cat to delete');
}
$sql = "DELETE FROM tableName WHERE columnName = '".$_GET['cat']."' ";
mysql_query($sql);
}
#1
0
while($rows = mysql_fetch_array($query)) {
echo "Category: <input type='text' name='category[]' value=".$rows['category']." />";
echo "<a href="UrlWhereCodeOfDleteToBEWrite?task=delete&cat=".$rows['category'].">Delete</a>";
}
In file the above link will redirect write as
在文件中,上面的链接将重定向写为
if(isset($_GET['task']) && $_GET['task'] == 'delete'){
if(!isset($_GET['cat'])){
die('Invalid cat to delete');
}
$sql = "DELETE FROM tableName WHERE columnName = '".$_GET['cat']."' ";
mysql_query($sql);
}