i create a simple shopping catalog..
when display 1 row = 3 items..
how to solve it ...
<%@ page import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>go to item product</title>
</head>
<body>
<%
String item = request.getParameter("catalog");
Connection Con = null;
PreparedStatement Ps = null;
ResultSet Rs = null;
String sDB="test",sUsr="",sPwd="";
String sSQL = "select * from product where product_catalog = '"+item+"' order by product_id";
//Detect JDBC-ODBC driver
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e) {
System.err.print("Jdbc.Open(): " + e.getMessage());
}
//connection to Database
try {
Con = DriverManager.getConnection(
"jdbc
dbc:" + sDB, sUsr, sPwd);
} catch (Exception e) {
System.err.print("Jdbc.Open(): " + e.getMessage());
}
//Run SQL Statement
try{
Ps = Con.prepareStatement(sSQL);
Rs = Ps.executeQuery();
}
catch(SQLException e){
System.err.println("Jdbc.Update(): " + e.getMessage());
}
%>
<table width='100%' border=0>
<tr>
<td align=center colspan=3><%= item %></td>
</tr>
<%
try {
while (Rs.next()){
if count mod 3=0 then
%>
<tr>
<td><p><a href="3.jsp?pid=<%=Rs.getString("product_id")%>">
<img src="<%=Rs.getString("product_desc")%>"><br>
<%=Rs.getString("product_name")%></a></p></td>
</tr>
<%
} else {
%>
<td><p><a href="3.jsp?pid=<%=Rs.getString("product_id")%>">
<img src="<%=Rs.getString("product_desc")%>"><br>
<%=Rs.getString("product_name")%></a></p></td>
<%
count=count+1
}
} catch (Exception e) {}
%>
</table>
</body>
<%
Con.close();
%>
</html>