|
|
|
<%
String productCategory = request.getParameter("productCategory");
String DRIVER = "org.gjt.mm.mysql.Driver";
Class.forName(DRIVER).newInstance();
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try{
String url="jdbc:mysql://p41mysql25.secureserver.net/zulzbula?user=zulzbula&password=aFHa1Ciab";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
%>
<%
rst=stmt.executeQuery("SELECT ProductId, ProductName, ProductCategoryName FROM `products` WHERE `ProductCategoryName` = '" + productCategory + "' order by `ProductId`");
%>
<%
// next three lines determine the number of rows in the result set
rst.last();
int numberOfRows = rst.getRow();
rst.beforeFirst();
int numPages;
int resultsOfDivision = numberOfRows / 9;
if(numberOfRows % 9 == 0) {
numPages = numberOfRows / 9;
}
else {
numPages = (numberOfRows / 9) + 1;
}
String pageNumber = request.getParameter("page");
if (pageNumber == null) {
pageNumber = "1";
}
int resultSetCursorPosition = 0; //will need this to be whatever page starting index
resultSetCursorPosition = (Integer.parseInt(pageNumber) * 9) - 9;
%>
|
<%
for ( int outerLoop = 0; outerLoop <3; outerLoop++ ) {
%>
<%
for ( int innerLoop = 0; innerLoop <3; innerLoop++ ) {
rst.absolute(resultSetCursorPosition + 1);
if(!rst.isAfterLast()){
%>
|
<%
} // end if
resultSetCursorPosition++;
} // end for
%>
<% }
rst.close();
con.close();
}catch(Exception e)
{
response.sendRedirect("missing.html");
} //end of try-catch block
%>
|
|
|
|