【发布时间】:2013-06-20 22:36:56
【问题描述】:
嗨,我使用 php 代码从我的 sql 中查看任何帖子的所有 cmets,我想为每条评论添加一个提交按钮,以便在不刷新页面的情况下删除它,我的意思是使用 AJAX 我不知道如何编写该代码并将其与我想添加的 html 代码连接起来,如下所示:
<form>
<input type="submit" id="deletecomment">
</form>
并将其与AJAX和delete.php页面连接以删除评论(ajax,delete.php)???????
这是我的代码
$result = mysql_query ("select * from post_comments WHERE link ='$getlink' order by link asc");
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$link = $row['link'];
$time = $row['time'];
$content = nl2br($row['content']);
$name = ($row['link'] != '') ? '<h3 style="color:blue">'.$row['name'].'</h3>' : $row['name'];
$imge = $row['imge'];
echo '
<div class="commentuserbackground">
<img src="'.$imge.'" width="30px" height="30px">
<div id="comment-'.$id.'" class="username1">'.$name.'</div>
<div class="username2">'.$content.'</div><div class="commenttime"><h4 style="color:#5a5a5a">'.$time.'</h4>
</div></div>';
}
【问题讨论】: