hi, iam retrieving data from the database using a while loop en pouring it out in table format as u can see below, along with a column that has a select tag included in the while loop,now the options for the select tag are;(pending and cleared),which at choice i want to use to update the respective database table,but the trouble is,when i press the update button,it updates all the values instead of the specific chosen.plz help.
html code
<tr>
<td width=50><div align="center"><%=datez%></div></td>
<td width=50><div align="center"><%=cashrecid%></div></td>
<td width=50><div align="center"><%=fname%></div></td>
<td width=50><div align="center"><%=lname%></div></td>
<td width=50><div align="center"><%=cashout%></div></td>
<td width=50><div align="center"><%=purpose%></div></td>
<td width=50><div align="center"><%=project%></div></td>
<td width=50><div align="center">
<select name="select" size="1" id="select">
<option value="pending">pending</option>
<option value="cleared">cleared</option>
</select>
</div></td>
</tr>
jsp code
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%! public int cashrecid; %>
<%
String uname=(String)session.getAttribute("theName");
String status=request.getParameter("select");
Connection con1=DriverManager.getConnection("jdbc:odbc:pettyz","sa","pass@word");
PreparedStatement stmt1=con1.prepareStatement("select cashrecid from cashrequisitions where status='pending' ");
ResultSet rs1=stmt1.executeQuery();
while(rs1.next()) {
cashrecid=rs1.getInt(1);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:pettyz","sa","pass@word");
PreparedStatement stmt=con.prepareStatement("update cashrequisitions set status=? where cashrecid=?");
stmt.setString(1,status);
stmt.setInt(2,cashrecid);
stmt.executeUpdate();
}
rs1.close();
stmt1.close();
con1.close();
%>