<%@ page language="java" import="java.sql.*"
pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
%><%!int GroupCount = 0; int Count = 0; int RowCount = 0; static String GroupSQL = "Select id,bigName From tb_bigType"; static String RowSQL = "Select * From tb_goods Where  bigId = "; public Connection Con() {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection Con = DriverManager
.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db",
"sa", "sa");
return Con;
} catch (Exception e) {
return null;
}
} public int GetCount(String SQL) {
try {
Connection Con = Con();
Statement Smt = Con
.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet Rs = Smt.executeQuery(SQL);
Rs.last();
return Rs.getRow();
} catch (SQLException e) {
System.out.println("组数量获取失败!");
return 0;
}
} public ResultSet GetRs(String SQL) {
try {
Connection Con = Con();
Statement Smt = Con
.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet Rs = Smt.executeQuery(SQL);
return Rs;
} catch (SQLException e) {
System.out.println("记录数量获取失败!");
return null;
}
}%>
<html>
  <body>
    <table width="710px" height="100%" cellspacing="0" cellpadding="0"
border="0" align="center" bgcolor="#FFFFF0">
<%
ResultSet GRs = GetRs(GroupSQL);
while (GRs.next()) {

%>
<tr>
<td height="23"> </td>
</tr>
<tr>
<td align="center" valign="top">
<!-- 内表格 -->
<table height="159" border="0" align="center"
style="width:710px;height:159;border:1px #b5cfdc solid;"
bgcolor="white"> <tr>
<td height="24" colspan="3">

<span class="style2"><strong><%=GRs.getString("bigName")%><%=GRs.getString("id") %></strong>
</span>
</td>
</tr> <tr>
<%
Count = GetCount(RowSQL + "'" + GRs.getString("id")
+ "'");//当前组总数
RowCount = Count / 5;//当前组行数
if (Count % 5 > 0)
RowCount=1;
ResultSet RRs = GetRs(RowSQL + "'" + GRs.getString("id")
+ "'");//当前组记录集
for (int j = 0; j < RowCount; j++) {
for (int n = (j) * 5; n < (j + 1) * 5; n++) {
RRs.absolute(n + 1);
if (RRs.isAfterLast())
break;
%>
<td width="178" height="129">
<!-- 图片表格 --> <%=RRs.getString("goodsName") %> <!-- 图片表格 -->
</td>
<%
}
%> </tr>
<%
}
%>
</table>
<!-- 内表格 -->
</td>
<%
}
%>
</tr>
</table>
  </body>
</html>