用ASP+XML實現CSDN的菜單(資料庫),可分許可權管理.

來源:互聯網
上載者:User

    我在開發公司OA系統的時候.想找一個CSDN的菜單.可是網上有這樣的代碼.可是不是基於資料庫,也不能按許可權管理.我就寫了一個.我的這個.只有一個程式檔案和一個資料庫.檔案很少,也很容易查錯.但是功能完全實現了!

資料庫結構:

Table:Menu
  ID
  parentid,int,4
  MenuName,Char,20
  Link,Char,50

Table:UserLevel
  ID
  UserID,int,4
  MenuID,int,4

-------------------------------------程式源檔案:MenuList.Asp------------------------------

'-------------------------------'
'源創商務策劃有限公司-OA系統
'模組名稱:可許可權控制的菜單
'-------------------------------'

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
%>

-----------------------------------------------------------------------------------------------------

原始碼下載:http://www.9559.cn/more.asp?name=David&id=4

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.