Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help jsp catalog table 1row = 3itmes

 
sorimachi wong
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sorimachi wong:

how to solve it ...


How to solve what?
 
sorimachi wong
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%
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) {}
%>

---------------------------------------------------

if count mod 3=0 then << this ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic