what iam trying to do is get field parameter and run mysql query to update(decrement) value from field quantity, can any one tell me how to do that?
<form method="post">
<table class="bordered">
<thead>
<tr>
<th>No</th>
<th>Drug Name</th>
<th>Strength</th>
<th>Quantity</th>
<th>Dis Qty</th>
</tr>
</thead>
<% try {
String query="select * from drugs";
Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery(query); while(rs.next()) {
%> <tr> <td><%=rs.getInt("drugid") %></td> <td><%=rs.getString("drugname") %></td> <td><%=rs.getString("strength") %></td> <td><%=rs.getInt("drugquant") %></td> <td><INPUT TYPE="TEXT" NAME="getint" SIZE="7">
<INPUT TYPE="SUBMIT" VALUE="Dispense" NAME="B1"></td> </tr>
<%
} %> </table>
<%
rs.close();
stmt.close();
conn.close();
} catch(Exception e) {
e.printStackTrace();
}
![enter image description here][1]
%>
</form>
I tryed to use code similar to this but it doesnt work for me :(
<%
String getint = request.getParameter("getint");
String getsize = "";
// check if Update button is clicked
if(request.getParameter("B1") != null) {
// get what user enterd in intbox
getint = request.getParameter("getint");
// DEBUG
PreparedStatement pstmt4;
pstmt4 = conn.prepareStatement("UPDATE drugs SET drugquant=drugquant - "+getint+" WHERE drugid=1");
pstmt4.executeUpdate();
}
%>
any one could help?