I created one table. Values in it will be dynamically created from the database. I add a checkbox at the last column. Now what I like to know is that, when the checkbox is selected that particular row alone want to be stored in new database, so according to how much checkbox is selected that much row should be added in the database. Can any one help me with this?
Thanks in advance...
My code:
<%@ page import="java.sql.*" %>
<%
String connectionURL = "";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
int f=0;
%>
<html>
<head>
<title>csepoff</title>
</head>
<body>
<form name="cse" action="csepoffcheck1.jsp">
<%
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connection = DriverManager.getConnection(connectionURL,"root","tajmahalss");
statement = connection.createStatement();
String[] batchcse=request.getParameterValues("batchcse");
String batchhcse="";
String data="";
String data1="";
String data2="";
for(int i=0; i<batchcse.length; i++) {
batchhcse+=batchcse[i]+" ";
}
rs=statement.executeQuery("select * from signup where batch='"+batchhcse+"'");
out.println("<table border='1'><tr>");
out.println("<th>NAME</th><th>DEPARTMENT</th><th>BATCH</th>");
out.println("<th>FATHER NAME</th><th>MOTHER NAME</th><th>SELECT</th>");
while(rs.next()){
out.println("<tr>");
out.println("<td>"+rs.getString("name")+"</td>");
out.println("<td>"+rs.getString("depart")+"</td>");
out.println("<td>"+rs.getString("batch")+"</td>");
out.println("<td>"+rs.getString("fname")+"</td>");
out.println("<td>"+rs.getString("mname")+"</td>");
out.println("<td><input type=\"checkbox\" name=\"checkbox\" value=\"${}\"></td>");
out.println("</tr>");
}
out.println("</table>");
%>
<input type="submit" value="SUBMIT">
</form>
</body>
</html>