【www.gdgbn.com--php与数据库】

< !-- #include virtual="Include/database.asp" -->
< %
set rs=Server.CreateObject("ADODB.RecordSet")
sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE (parent_id = (SELECT id FROM enter_individual WHERE menu_flag = "root" )) " "查询得到根节点
rs.Open sql,conn,1,1
Response.Write "< table width=100% border=0 cellspacing=1 cellpadding=0 align=center>< tr bgcolor=#3399CC valign=bottom align=center>"
sumnum=rs.RecordCount
myArray=rs.GetRows()
rs.Close ()
widd=780/sumnum "从一级子菜单数目判断弹出菜单x坐标的递增像素
dim i
i=0
defaultbgcolor="#3399cc" "指定默认底色
defaultcolor="#ffffff" "指定默认字体颜色
defaultlink="#" "指定默认链接
posit_x=0 "x位置
flag=1 "标志,作为菜单弹出方向 1表示向右,0表示向左
"Response.Write myArray(4,6)
while i Response.Write "< td height=20 bgcolor="&myArray(2,i)&" width="&widd&">< a href="&myArray(1,i)&" onmouseover=java script:a"&myArray(4,i)&".style.display="block" onmouseout=java script:a"&myArray(4,i)&".style.display="none" >< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /a>< /td>"
"-----------------------------------------------
i=i+1
Wend
Response.Write "< /tr>< /table>"
i=0
while i posit_y=100 "y位置回到原位
If i>=(sumnum/2) Then "如果菜单进入右半部分,则弹出转向
flag=0
End If
"调用GetSubMenu 函数 设置该项一级菜单的下级菜单,以myArray(4,i) 即菜单id作为下级菜单所在div 的id
GetSubMenu myArray(4,i),posit_x,posit_y
posit_x=posit_x+widd "下一个一级菜单的子菜单的 x坐标值增加一个单位
i=i+1
Wend
"使用递规算法的到下级菜单的函数
"parent_id 父 id; posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置;

本文来源:http://www.gdgbn.com/jiaocheng/2796/