良好的知名度和信誉度,经验丰富的团队!

多年来我们为不同行业的知名企业进行了网络品牌重塑,一路的学习、摸索、沉淀、创新,让我们更自信和充满活力。
提升客户品牌形象、实现客户的商业目标是亿络永恒的追求!

详细内容
当前位置:首页 > 新闻资讯 > 网站建设知识

asp中无限级分类生成数组

标签:  来源:  发布时间:2011-04-15 21:12:30

asp无限级分类有很多种调用方法和读取方面,下面介绍将无限级分类使用数组操作方法,改天有空再写递归无限级分类。

返回所有分类的数组,并按顺序排列
有4个属性:
set aa=new classlist
aa.id="id"//编号的名称
aa.classname="classname"//分类名称
aa.pid="pid"//父ID名称
aa.db_name="class"//表名
list=aa.arrylist()

<%
class classlist
private c_id
private c_db_name
private c_pid
private c_classname
public property let id(str)
c_id = str
end property
public property let db_name(str)
c_db_name = str
end property
public property let pid(str)
c_pid = str
end property
public property let classname(str)
c_classname = str
end property

dim list()

dim i,n
Private Sub Class_Initialize()'初始化变量
i=0
n=0
End Sub


public function classarry(thisid,pid)'取得下级ID
if pid>0 then
sql="select * from "&c_db_name&" where "&c_pid&"="&thisid
else
sql="select * from "&c_db_name&" where "&c_id&"="&thisid
end if
set rs_c=conn.execute(sql)
n=n+1

do while not rs_c.eof

list(0,i)=rs_c(c_id)'装入数组中
list(1,i)=rs_c(c_classname)
list(2,i)=n
'n=n+1
i=i+1
thisid=classarry(rs_c(c_id),1)'这里递归调用,直到最后一个子类

rs_c.movenext
loop
n=n-1
rs_c.close

end function

public function arrylist()'循环出所有根类
set rs_c=conn.execute("select count("&c_id&") from "&c_db_name)
lenght=rs_c(0)
rs_c.close
redim list(2,lenght)'设置数组
set rs1=conn.execute("select "&c_id&" from "&c_db_name&" where "&c_pid&"=0")
do while not rs1.eof
call classarry(rs1(c_id),0)
'n=1
rs1.movenext
loop
rs1.close
arrylist=list
end function

end class
%>
 

以上是关于asp把无限级分类写入数组中的操作方法。

分享到:
业务咨询
点击这里给我发消息
业务咨询
点击这里给我发消息
技术支持
点击这里给我发消息