I am having problem updating the a db table . Let me first post the code
<%
String query="select * from COURSE";
Connection con=RegisterDao.connect();
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs=ps.executeQuery();
%>
<form action="Faculty_Course.jsp" method="POST">
<table align="center" cellpadding = "10" id="table_td">
<tr> <td></td>
<td ><b>Name</b></td>
<td ><b>Duration(in months)</b></td>
<td ><b>Start Date</b></td>
<td ><b>End Date</b></td>
<td ><b>Fees(in $)</b></td>
<td><b> Faculty</b></td>
</tr>
<%
while(rs.next()){
%>
<tr width=20% style="color:black">
<td ><input type="radio" name="name" style="display: inline" value='<%= rs.getString(1)%>' /></td>
<td><%= rs.getString(1) %></td>
<td><%= rs.getString(2) %></td>
<td><%= rs.getString(3) %></td>
<td><%= rs.getString(4) %></td>
<td><%= rs.getString(5) %></td>
<td>
<select>
<%
String query1="select * from STAFF_REGISTER";
PreparedStatement ps2=con.prepareStatement(query1);
ResultSet rs2=ps2.executeQuery();
while(rs2.next()) {%>
<option name="emailid" value='<%= rs2.getString(3) %>'><%= rs2.getString(3) %></option>
</select>
</td>
</tr>
<% }
}
%>
</table>
<input type="submit" name="submit" value="UPDATE"
style="margin-left:50%;font-size: 22px;background-color: lightblue;color:black"/>
</form>
<%
String name=request.getParameter("name");
String emailid=request.getParameter("emailid");
System.out.println(name+" "+emailid);
if(name!=null && emailid!=null){
String insert_query="insert into FAC_COURSE values (?,?)";
PreparedStatement ps3=con.prepareStatement(insert_query);
ps3.setString(1, name);
ps3.setString(2, emailid);
int rs1=ps3.executeUpdate();
}
%>
Here I am trying to fetch value from course table and from emailid from staff_register and trying to insert them into a third table fac_course. But after clicking the submit button it's not entering. I also tried printing the values through the System.out.println(name+" "+emailid);
to check if they are printed on console . after clicking submit only the name is printed but not emailid . the emailids' are showing in the dropdown list. So I am a bit confused about the problem .