Hello guys,
I have been working on a shopping site. i need to create different number of buttons in the
jsp page according to the database.
this is my code
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<html>
<head>
<script language="javascript">
</script>
<title>Solitude:Furniture-3</title>
</head>
<body>
<%
try {
String connectionURL = "jdbc:mysql://localhost:3306/login";
Connection connection = null;
Statement statement = null;
ResultSet rs= null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
statement = connection.createStatement();
String QueryString = "SELECT * from revolvingchair";
rs = statement.executeQuery(QueryString);
String s[];
int i=10;
%>
<TABLE cellpadding="15" border="1" style="background-color: #ffffcc;">
<thead>
<th>Item ID</th> <th>Item Name</th> <th>Item Description</th> <th>Item Price</th> <th>Item Available</th> <th>Quantity</th>
</thead>
<%
while (rs.next()) {
%>
<TR>
<TD><%=rs.getInt(1)%></TD>
<TD><%=rs.getString(2)%></TD>
<TD><%=rs.getString(3)%></TD>
<TD><%=rs.getInt(4)%></TD>
<TD><%=rs.getInt(5)%></TD>
<TD><input name="<% rs.getString(2);%>" type="submit" value="AddtoCart" /></TD></TR>
<% i++;
} %>
<%
rs.close();
statement.close();
connection.close();
} catch (Exception ex) {
out.println("Unable to connect to database.");
}
%>
<input type="submit" value="Add" name="AddtoCart" ></input>
</TABLE><TABLE>
<TR>
</TR>
</TABLE>
</form>
</body>
</html>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
My particular problem is i cannot differentiate the buttons when the user clicks the name wich i have given is taking as null please help me how to declare distinct names to buttons