Home > Database > Mysql Tutorial > body text

JSP实现论坛树型结构的具体算法_MySQL

WBOY
Release: 2016-06-01 14:11:05
Original
959 people have browsed it

  实现论坛树型结构的算法很多,我现在的JSP论坛采用的也是当中的一种:不用递归实现树型结构的算法,现在我将论坛树型结构的具体算法和大家介绍一下,和大家一起交流。






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("
    ");
    }
    out.print("
  • ");
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template