0

嗨,我完全迷路了,我有一个使用用户安全级别自行创建的菜单

但是我不知道如何显示子菜单我的桌子上有一个 parentid 但不知道如何在代码中实现有人可以帮助我输入我的模板代码

Dim CurrentSecLev                   'security level of the requested menu item
Dim MenuLink                        'filename or url of the menu item
Dim MenuText                        'display text of the menu item

'build sql query string, open database, and execute the query
strSQL = "SELECT * FROM dbo.tblMenus where mnuParentID = 0 ORDER BY mnuOrder"
objConn.Open
set objResults=objConn.Execute(strsql)

'loop through the records and build the menu
do while not objResults.eof
CurrentSecLev=objResults("mnuSecLev")
MenuLink=objResults("mnuLink")
MenuText=objResults("mnuText")

'check to ensure that the users security level meets or exceeds the required
'security level of the current menu item.  This ensures that only authorized
'users see certain menu items, such as 'Site Admin'.
if MySecLev => CurrentSecLev then
    response.write "<li><a href='" & MenuLink & "'>" & MenuText & "</a></li>" & vbcrlf
        end if
'rock on
objResults.Movenext
Loop

'close and destroy the recordset, close the database.
objResults.Close
set objResults=Nothing
objConn.Close

'check to see if the user is logged in.  if they are, display the logout
'option.  if they are not logged in, display the login option.
If LoggedIn="Yes" Then 
response.write "<li><a href='logout.asp'>Logout</a></li>" & vbcrlf
Else
response.write "<li><a href='login.asp'>Login</a></li>" & vbcrlf
End if
%></ul><Form Action="searchresults.asp" method=post id=form3 name=form3><p><input   name="searchquery" id="searchquery" size="10"/><input name="Submit" id="Submit" type="submit" value="Search!" /></p></form>
<p>&nbsp;</p>
<%
Dim rsArray 
Dim rs
objConn.Open
strSQL = "SELECT * FROM tblKBMain where title <> '' or [content] <> ''"
Set rs = objconn.execute(strSQL) 
if not rs.eof then 
rsArray = rs.GetRows() 
nr = UBound(rsArray, 2) + 1 
Response.write "<p>" & nr & " articles</p>" 
end if 
rs.close
set rs = nothing 
objConn.Close
%>

</div>
4

1 回答 1

0

好的,快速查看您的代码。但我只会为您提供子菜单的基本指南。

如果您使用的是子菜单,那么您需要在表中设置一个您已经拥有的 parentID。parentID 将等于其“父级”的 menuID。即,如果“文件”的 menuID 为 1,则“打开”的 parentID 为 1。所有顶级菜单的 parentID 为 0。

然后查询 parentID=0 的菜单表。

For each menu item, 
  you first display it,
  Then you do another query on the same table where parentID={the menuID of the item you just displayed},
  Then for each one of those, 
    you again display it.
    If you have 3 levels of menus, do yet another query for those.  
      ...  
    end loop of level 3  
  end loop of level 2  
end loop of level 1

菜单项的显示因您使用的方法而异。大多数使用

<ul><li>

谷歌搜索 CSS 菜单。

于 2013-04-23T20:17:27.787 回答