获取父分类,子分类列表

'======================
'获取子分类列表用 逗号隔开
childrenIDS=""
'SortList(0)
function SortList(ParentID)
 Dim rs : set rs =Exec ("select *,(select count(*) from web_menu where tid=t.id) as c from web_menu t where tid="&ParentID,"r1")
 If not rs.eof Then
  Do While not rs.eof  
   if childrenIDS="" then
    childrenIDS=rs("id")
   else
    childrenIDS=childrenIDS&","&rs("id")
   end if
   SortList(rs("id"))
   rs.MoveNext
  Loop
  rs.close : set rs = nothing
 End If
End function
'例子:
'SortList(45)
'echo childrenIDS
'=============================
'获取父id列表
parentIDS=""
function getParents(theID)
 
 id=0
 set rsGetp=exec("select tid from web_menu where id="&theID,"r1")
 if not rsGetp.eof then
  id=rsGetp(0)
 end if
 rsGetp.close : set rsGetp=nothing
 if id=21 or id=0 then
  exit function
 end if
 if parentIDS="" then
  parentIDS=id
 else
  parentIDS=id&","&parentIDS
 end if
 getParents(id)
 
end function
'获取产品的分类列表 用逗号,隔开
function getps(theID)
 parentIDS=theID
 getParents(theID)
 getps=parentIDS
end function

'例子:
'response.Write(getps(47))
'================================

posted on 2011-05-19 16:09  woshilee  阅读(357)  评论(0)    收藏  举报

导航