• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help jsp catalog table 1row = 3itmes

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic