展开全部
建一个表fenlei,包括字段如下:
id,name,level,follow
id为标识[自动编号]
name为分类名称[字符]
level为分类级别[数字,不可为空]
follow为从属于哪个分类[数字,默认为0]
假设表中内容为:
id | name | level | follow
1 | biga | 1 | 0
2 | bigb | 1 | 0
3 | sa | 2 | 1
4 | ssa | 3 | 3
sql="select * from fenlei where level = 1 and follow =0"
set rs=conn.execute(sql)
do while not rs.eof
response.write rs("id")&"."&rs("name")&"<br>"
sql1="select * from fenlei where level = 2 and follow = "&rs("id")
set rs1=conn.execute(sql)
do while not rs1.eof
response.write rs("id")&"."&rs1("id")&"."&rs1("name")&"<br>"
sql2="select * from fenlei where level = 3 and follow = "&rs1("id")
rs2=conn.execute(sql)
do while not rs2.eof
response.write rs("id")&"."&rs1("id")&"."&rs2("id")&"."&rs2("name")&"<br>"
rs2.movenext
loop
rs1.movenext
loop
rs.movenext
loop
注:conn为数据库连接
以上三个循环掌握住了以及数据库中各记录的关系掌握了就没有大问题了,具体代码的问题请参考你的教科书。哦呵呵呵~
id,name,level,follow
id为标识[自动编号]
name为分类名称[字符]
level为分类级别[数字,不可为空]
follow为从属于哪个分类[数字,默认为0]
假设表中内容为:
id | name | level | follow
1 | biga | 1 | 0
2 | bigb | 1 | 0
3 | sa | 2 | 1
4 | ssa | 3 | 3
sql="select * from fenlei where level = 1 and follow =0"
set rs=conn.execute(sql)
do while not rs.eof
response.write rs("id")&"."&rs("name")&"<br>"
sql1="select * from fenlei where level = 2 and follow = "&rs("id")
set rs1=conn.execute(sql)
do while not rs1.eof
response.write rs("id")&"."&rs1("id")&"."&rs1("name")&"<br>"
sql2="select * from fenlei where level = 3 and follow = "&rs1("id")
rs2=conn.execute(sql)
do while not rs2.eof
response.write rs("id")&"."&rs1("id")&"."&rs2("id")&"."&rs2("name")&"<br>"
rs2.movenext
loop
rs1.movenext
loop
rs.movenext
loop
注:conn为数据库连接
以上三个循环掌握住了以及数据库中各记录的关系掌握了就没有大问题了,具体代码的问题请参考你的教科书。哦呵呵呵~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询