怎么用asp实现双循环,谢谢了
1个回答
展开全部
Sub Main_Menu()
Response.Write "<ul id=""nav"">"&vblf
str="select id,Name From Model_channel where show=1 order by sort"
set rst=Server.CreateObject("Adodb.Recordset")
rst.open str,conn,1,1
if not rst.eof then
do while not rst.eof
Response.Write"<li class=""mainlevel"" id=""mainlevel_0"&menuid&"""><a href=""newslist.asp?Pid="&rst("id")&""">"&rst("name")&"</a>"&vblf
Response.Write" <ul id=""sub_0"&menuid&""">"&vblf
menustr3="select id,Name From Model_cate where Channel="&rst("id")&" order by sort"
set menu3=server.CreateObject("adodb.recordset")
menu3.open menustr3,conn,1,1
if not menu3.eof then
do while not menu3.eof
Response.Write" <li><a href=""newslist.asp?Pid="&rst("id")&"&Cid="&menu3("id")&" "">"&menu3("Name")&"</a></li>"&vblf
menu3.Movenext
loop
End if
menu3.close
Set menu3=Nothing
Response.Write" </ul>"&vblf
Response.Write"</li>"&vblf
menuid=menuid+1
rst.MoveNext
Loop
End if
rst.close
set rst=Nothing
Response.write "</ul>"&vblf
End Sub
调用直接 Main_Menu()
Response.Write "<ul id=""nav"">"&vblf
str="select id,Name From Model_channel where show=1 order by sort"
set rst=Server.CreateObject("Adodb.Recordset")
rst.open str,conn,1,1
if not rst.eof then
do while not rst.eof
Response.Write"<li class=""mainlevel"" id=""mainlevel_0"&menuid&"""><a href=""newslist.asp?Pid="&rst("id")&""">"&rst("name")&"</a>"&vblf
Response.Write" <ul id=""sub_0"&menuid&""">"&vblf
menustr3="select id,Name From Model_cate where Channel="&rst("id")&" order by sort"
set menu3=server.CreateObject("adodb.recordset")
menu3.open menustr3,conn,1,1
if not menu3.eof then
do while not menu3.eof
Response.Write" <li><a href=""newslist.asp?Pid="&rst("id")&"&Cid="&menu3("id")&" "">"&menu3("Name")&"</a></li>"&vblf
menu3.Movenext
loop
End if
menu3.close
Set menu3=Nothing
Response.Write" </ul>"&vblf
Response.Write"</li>"&vblf
menuid=menuid+1
rst.MoveNext
Loop
End if
rst.close
set rst=Nothing
Response.write "</ul>"&vblf
End Sub
调用直接 Main_Menu()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询