aspose file tools*
The moose likes JSP and the fly likes help jsp catalog table 1row = 3itmes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "help jsp catalog table 1row = 3itmes" Watch "help jsp catalog table 1row = 3itmes" New topic
Author

help jsp catalog table 1row = 3itmes

sorimachi wong
Greenhorn

Joined: Apr 07, 2006
Posts: 3
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

Joined: Jan 10, 2002
Posts: 61612
    
  67

Originally posted by sorimachi wong:

how to solve it ...


How to solve what?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sorimachi wong
Greenhorn

Joined: Apr 07, 2006
Posts: 3
<%
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 ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help jsp catalog table 1row = 3itmes