最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
不用递归实现论坛树型结构的算法
时间:2022-07-02 17:58:06 编辑:袖梨 来源:一聚教程网
<jsp:useBean id="mybbs" scope="session" class="netzero.mydb" />
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%
int intRowCount;
out.print("显示论坛树形结构");
out.print("
");
try {
String sql="select * from mybbslist order by rootid desc,depth,fid,bbsid";
ResultSet rs = mybbs.executeQuery(sql);
if (rs.next())
{
rs.last();
intRowCount=rs.getRow();
out.print("论坛树中有");
out.print(intRowCount);
out.print("个叶子节点");
rs.first();
int j=0;
int Depth = 0;
out.print("
}
}
rsDepth=rs.getInt("Depth");
if (rsDepth>Depth)
{
out.print("
}
else
{
out.print("数据库中无记录");
}
}catch (SQLException E) {
out.println("SQLException: " + E.getMessage());
out.println("SQLState: " + E.getSQLState());
out.println("VendorError: " + E.getErrorCode());
}
%>
<% //关闭mysql连接
try {
if(!mybbs.closeConn());
} catch (Exception ex) {
System.err.println("closeConn: " + ex.getMessage());
}
%>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%
int intRowCount;
out.print("显示论坛树形结构");
out.print("
");
try {
String sql="select * from mybbslist order by rootid desc,depth,fid,bbsid";
ResultSet rs = mybbs.executeQuery(sql);
if (rs.next())
{
rs.last();
intRowCount=rs.getRow();
out.print("论坛树中有");
out.print(intRowCount);
out.print("个叶子节点");
rs.first();
int j=0;
int Depth = 0;
out.print("
- ");
while(j
int rsDepth=rs.getInt("Depth");
if (rsDepth
for(int i=1;i
out.print("
}
}
rsDepth=rs.getInt("Depth");
if (rsDepth>Depth)
{
out.print("
- ");
- ");
String bbssubject=rs.getString("bbssubject");
out.print(bbssubject);
out.print(" ");
}
out.print("
Depth = rs.getInt("Depth");
j=j+1;
rs.next();
}
out.print("
}
else
{
out.print("数据库中无记录");
}
}catch (SQLException E) {
out.println("SQLException: " + E.getMessage());
out.println("SQLState: " + E.getSQLState());
out.println("VendorError: " + E.getErrorCode());
}
%>
<% //关闭mysql连接
try {
if(!mybbs.closeConn());
} catch (Exception ex) {
System.err.println("closeConn: " + ex.getMessage());
}
%>
相关文章
- 以闪亮之名店长体验流霞季怎么玩 缘溪临霞套装活动介绍 12-31
- 未定事件簿旧梦新生左然篇怎么玩 旧梦新生左然篇活动介绍 12-31
- 未定事件簿左然破浪远行怎么样 12-31
- 桃源深处有人家行医问诊怎么玩 12-31
- 恋与制作人跨年福利有哪些 恋与制作人跨年福利内容介绍 12-31
- 阴阳师协同对弈大乱斗怎么玩 阴阳师协同对弈大乱斗活动介绍 12-31