日期:2014-05-17 浏览次数:20663 次
if(DBShowreview.deleteReview(Integer.parseInt(id),Integer.parseInt(content_id))){
resp.sendRedirect("reviewmanage.jsp?id="+content_id);
}
else{
resp.sendRedirect("review.jsp?id="+content_id);
}
public static boolean deleteReview(int review_id,int content_id){
connect();
// 删除指定回复。
String sql = "delete from review where review_id=?";
// 让 帖子的回复次数减1.
String sql1 ="update content set count=count-1 where content_id=?";
try {
psmt =conn.prepareStatement(sql);
psmt.setInt(1,review_id);
int i = psmt.executeUpdate();
psmt =conn.prepareStatement(sql1);
psmt.setInt(1,content_id);
int j = psmt.executeUpdate();
if(0!=i&&0!=j){
return true;
}
psmt.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
function show_delete()这样拼接应该没错吧。 delete是个单选框的name,它的value值就是review_id
{
var review_id;
var checkboxs = document.getElementsByName("delete");
for(var i = 0 ; i<checkboxs.length;i++)
{
if(checkboxs[i].checked)
{
review_id =checkboxs[i].value;
}
}
var r = confirm("确定要删除此回复么 ?");
if(r==true){
window.location.href="deletereview?id="+review_id+"&content_id="+<%=id%>;
}
}