注册 登录
编程论坛 ASP技术论坛

做成像树型菜单一样的效果,不过我先要把数据库的数据按大小类循环出来

wuna421123 发布于 2011-07-17 16:50, 445 次点击
//读出大类传一个主键ID
  SQL="select consultingid,Consultingname,pid from Consulting where pid=1 order by consultingid asc"
  Call Data.Execute(SQL,RS,false)
  while not RS.eof
   ss=ss+""&RS("Consultingname")&""+","
   dim cid
   cid=RS("consultingid")
//Response.Write RS("Consultingname")
RS.movenext
wend
array=split(ss,",",-1,1)
  Response.write array(2)


//根据大类传ID读出小类?
SQL="select * from consulting where pid='"&cid&"' order by consultingid asc "
call data.Execute(SQL,RS,false)
while not RS.EOF
tt=tt+""&RS("Consultingname")&""+","
Response.Write" "
dim did
did=RS("consultingid")
dim array2
RS.movenext
wend
array2=split(tt,",",-1,1)
  Response.write array2(0)
//Response.Write "<br>"
Response.Write did
Response.Write"<br>"

//根据小类的ID找对应的问题
SQL="select a.consultingid,Consultingname,pid from consulting as a inner join  consultingmodule as b on a.consultingid=b.consultingid where a.consultingid='"&did&"' order by a.consultingid asc"
SQL="select * from consultingmodule where consultingid='"&did&"'"
call data.Execute(SQL,RS,false)
while not RS.EOF
cc=RS("Consultingtitle")
//zz=RS("consultingproblem")
consulting3=consutling3+""&cc&"</br>"
RS.movenext
wend
//for i=0 to ubound(array)
// Response.write array(j)
//Response.Write(consulting3)
%>
2 回复
#2
QQ2730809732011-07-17 22:38
SQL="select a.consultingid,Consultingname,pid from consulting as a inner join  consultingmodule as b on a.consultingid=b.consultingid where a.consultingid='"&did&"' order by a.consultingid asc"
应该是这出问题了,把你数据库贴出来看看。
#3
liang1982072011-07-17 23:05
你的思想很正确啊,怎么还能写不出来呢。
Sub getchild(firstid,j)
selcet...........where id=firstid //数据查询
response.write()......//前台显示
////第一层查完了吧
Call getchild(rs("nodeid"),j+1)///rs("nodeid")为第二层的父节点从第一层的子节点可获得
//
end Sub
1