When I was developing my OA system. find a csdn menu. but there is such code on the Internet. can it be based on databases or cannot be managed by permissions. I wrote one. my. there is only one program file and one Database. very few files, and it is easy to find errors. but the function is fully implemented!
Database Structure:
Table: Menu
ID
Parentid, Int, 4
Menuname, Char, 20
Link, Char, 50
Table: userlevel
ID
Userid, Int, 4
Menuid, Int, 4
----------------------------------- Program source file: menulist. asp ------------------------------
'-------------------------------'
'Yuanchuang business planning Co., Ltd.-OA system
'Module name: menu with permission Control
'-------------------------------'
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open ("provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("tree. mdb") + "; persist Security info = false ")
%>
Set rs = Conn. execute ("select (select count (*) from menu where menu. parentid = x. ID and menu. ID in (select userlevel. menuid from userlevel where userlevel. userid = 1) as children, * From menu as X where X. ID in (select userlevel. menuid from userlevel where userlevel. userid = 1 )")
?
? Do while not Rs. EOF
? If RS ("parentid") = 0 then
?? Count = RS ("children ")
?? %>
? "Href =" "open =" false "treeid =" ">
?? ?? Rs. movenext
? End if
?
? For I = 1 to count
??? %>
????????????? ? "Href =" "open =" false "treeid =" ">
??
??? ??? Rs. movenext
? Next
? Response. Write (" ")
Loop
Rs. Close
Conn. Close
Set rs = nothing
Set conn = nothing
%>
Bytes -----------------------------------------------------------------------------------------------------
Source code download: http://www.9559.cn/more.asp? Name = David & id = 4