'获得大类 dim first dim i set rs=server.CreateObject("adodb.recordset") sql="select * from catalogs where parentid=0 order by id asc" rs.open sql,conn,3,1 first=rs.GetRows() rs.close set rs=nothing response.Write("bigclass-----------------------"&ubound(first,2)&"---------------- ")
'获得所有par_id=<>的类别------主类:par_id=0 if(ubound(first,2)<0) then response.Write("暂时没有分类") end if
Function getcatalogs(parentid,str) Dim Sql,rstemp,TemptempStr,tempStr tempStr=str&" " sql="select * from catalogs where parentid="&parentid Set rstemp = Conn.Execute(Sql) do while Not rstemp.Eof getcatalogs = getcatalogs &tempStr&"└"&rstemp("id")&":"& rstemp("title")&" " getcatalogs = getcatalogs & getcatalogs(rstemp("id"),tempStr) rstemp.MoveNext loop Set rstemp = Nothing End Function for i=0 to ubound(first,2) response.Write(first(0,i)&"-"&first(2,i)&" ") response.Write(getcatalogs(first(0,i),"")) ' next %>
|