我想选中此网页上的两个复选框以删除这些行。但是,当我按下删除按钮时,它显示“ 0条记录已删除”。此外,我检查的两行数据都没有删除。我该怎么做才能解决这个问题?
显示(勾选2个框):
点击删除按钮后显示的网页:
我的删除按钮的代码
<%
String[] ids = request.getParameterValues("userAction");
int count=0;
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// Step 2: Define Connection URL
String connURL = "jdbc:mysql://localhost/medicloud?user=root&password=root";
// Step 3: Establish connection to URL
conn = DriverManager.getConnection(connURL);
if (ids != null)
{
for(int i=0; i<ids.length; i++){
String sqlStr = "DELETE from exercise1 && exercise2 WHERE id=?";
PreparedStatement pstmt = conn.prepareStatement(sqlStr);
pstmt.setInt(1, Integer.parseInt(ids[i]));
//pstmt.setInt(1, Integer.parseInt(ids[i]));
int rec=pstmt.executeUpdate();
if (rec==1)
count++;
}
}
//System.out.println(functions);
%>
<form action="exercise.jsp" method="post">
<label><%=count%> record(s) deleted!!</label>
<input type="submit" value="Return" name="ReturnBtn" />
</form>
<%
conn.close();
} catch (Exception e) {
out.println(e);
}
%>