Я в основном пытаюсь сгенерировать количество форм исходя из количества элементов в базе данных, как мне сделать так, чтобы каждое имя формы было уникальным, моя идея состояла в том, чтобы назвать его "bid1" ... "bid2"... путем создания строки с "bid" + item_id. Хотя я не уверен, как использовать строку в html.
ResultSet rs = st.executeQuery("select * from auctionItem"); //loads database, already connected
while (rs.next() != false){ // while not end of database
String formname = "bid" + rs.getString(7); //create the formname
if (request.getParameter(formname) != null){ //check If I got input from the form
out.println("got input -------------------------------------------------");//just for testing to see if it ran
int currentBid = Integer.parseInt(rs.getString(6));
int newBid = Integer.parseInt(request.getParameter(formname));
if (newBid > currentBid){ //checks if bid is larger then current bid
int i = st.executeUpdate("UPDATE autionItem SET currentBid = " + newBid); //Im trying to use this to change the bid but I dont think that its getting the input
}
}
PRODUCT: <%= rs.getString(1) %> //outputs each item in table
DESCRIPTION: <%= rs.getString(2) %> <br>
SOLD BY: <%= rs.getString(3) %> <br>
Listed: <%= rs.getString(4) %>
Ends: <%= rs.getString(5) %><br>
Current Bid: <%= rs.getString(6) %> //Below is basically if they are logged in show the forms
Place Bid: <%if (session.getAttribute("loggedIn") == "true") { %><form method = "post" action = "mainSite.jsp"><input type="text" name="<%formname%>"><input type = "submit"></form>
<%}
else out.println("Log in or register to bid!");
%>