<ul id="verticalmenu" class="glossymenu" >
<%
'例:
'c_name c_code
'苹果 0001
'iPhone3Gs 00010001
'iPhone4 00010002
'摩托罗拉 0002
'摩托罗拉ME525 00020001
'摩托E6 00020002
'查询所有一级菜单
strSQL= "Select id,c_name,c_code From TableName Where mn_id= 160 and len(c_code) " &
" = 4 Order by c_code"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open strSQL,conn,1,1
for i=1 to rs.recordcount
sParm = ""
%>
<li><a href = "works.asp?class=<%=rs("id")%>"><%=trim(rs("c_name"))%></a>
<%
'查询所有二级菜单
sSqlAllSecond = "Select id,c_name,c_code From TableName Where mn_id= 160 and len(c_code) = "
& "8 Order by c_code"
Set rsAllClass = Server.CreateObject("ADODB.RecordSet")
rsAllClass.open sSqlAllSecond,conn,1,1
'遍历所有二级菜单
for z = 1 to rsAllClass.RecordCount
leftCode = Left(rsAllClass("c_code"),4)
If(rs("c_code")=leftCode) Then
'查询匹配的菜单项
sSqlSecond = "Select id,c_name,c_code From TableName Where mn_id= 160 and left(c_code,4) = "
& leftCode & " and len(c_code) > 4 Order by c_code"
Set rsSecondClass = Server.CreateObject("ADODB.RecordSet")
rsSecondClass.open sSqlSecond,conn,1,1
%>
<%Response.Write("<ul>")
for j=1 to rsSecondClass.RecordCount
Response.Write("<li> <a href = '#'>" & rsSecondClass("c_name") & "</a></li>" )
rsSecondClass.MoveNext
Next
Response.Write("</ul>")
Else
Response.Write(" ")
%>
<%End If
rsAllClass.MoveNext
Next
%>
</li>
<%
rs.movenext
next
%>
<!--
<li><a href = "#">联想</a></li>
<li><a href = "#">诺基亚</a></li>
<li><a href = "#">摩托罗拉</a></li>
<li><a href = "#">苹果</a>
<ul>
<li><a href = "#">iPhone3</a></li>
<li><a href = "#">iPhone4</a></li>
</ul>
</li>
<li><a href = "#">其他</a></li>
-->
</ul>