在php中:
if (isset($close_subject)) {
$sql_close = "delete from content_tree where user_id='$id' and subject_id='$close_subject'";
$result_close = mysql_query($sql_close);
}
function xxx()
{
<a href="#" onClick="closeSubject('<? echo $set_subject[subject_id] ?>')"><img border="0" align="absmiddle" src="../../pic/tree/open.png"></a>
}
在HTML中:
xxx();
<script type="text/javascript">
function closeSubject(id)
{
document.close_subject_form.close_subject.value = id;
document.close_subject_form.submit();
}
</script>
<form name="close_subject_form" method="POST">
<input type="hidden" id="close_subject" name="close_subject">
</form>
嗨,我有一些像上面这样的代码。我想删除数据库中的记录。但它不是功能&gt;。有人可以帮忙吗?
答案 0 :(得分:0)
function deleteshit($id,$close_subject){
mysql_query("delete from content_tree where user_id='".mysql_real_escape_string($id)."' and subject_id='".mysql_real_escape_string($close_subject)."'");
return mysql_affected_rows();
}
另外,如果与最佳猜测相反,你知道自己在做什么,请看看这个糟糕的http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers