asp如何循环生成这样的<ul><li>
<li>网站首页</li><li>大类名字1</li><ul><li>小类名字1</li><li>小类名字2</li></ul><li>大类名字2</li><ul><li...
<li>网站首页</li>
<li>大类名字1</li>
<ul><li>小类名字1</li>
<li>小类名字2</li>
</ul>
<li>大类名字2</li>
<ul><li>小类名字1</li>
<li>小类名字2</li>
</ul>
两个数据表 分别是大类名字 和小类名字 展开
<li>大类名字1</li>
<ul><li>小类名字1</li>
<li>小类名字2</li>
</ul>
<li>大类名字2</li>
<ul><li>小类名字1</li>
<li>小类名字2</li>
</ul>
两个数据表 分别是大类名字 和小类名字 展开
展开全部
嵌套循环~大循环里套个小循环~以前写过的~你自己对应自己的表改改吧~
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
menuid=2
Response.Write"<li class=""mainlevel"" id=""mainlevel_01""><a href=""index.asp"">首页</a>"&vblf
'Response.Write" <ul id=""sub_01""></ul>"
Response.Write"</li>"&vblf
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
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
menuid=2
Response.Write"<li class=""mainlevel"" id=""mainlevel_01""><a href=""index.asp"">首页</a>"&vblf
'Response.Write" <ul id=""sub_01""></ul>"
Response.Write"</li>"&vblf
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询