asp无限分类的问题。高手请指点
新手刚学asp不久。能写一般的网站程序。后来需要做无限分类的,就是商城。不会做。还有划分管理员等级。怎么划分。有没有高手指点一下,并给出相应的代码,并说明。小生终生感激。...
新手刚学asp不久。能写一般的网站程序。后来需要做无限分类的,就是商城。不会做。还有划分管理员等级。怎么划分。
有没有高手指点一下,并给出相应的代码,并说明。小生终生感激。混饭吃太难了,求高手指点迷经!
把所有分都给你,只有这么点了。 展开
有没有高手指点一下,并给出相应的代码,并说明。小生终生感激。混饭吃太难了,求高手指点迷经!
把所有分都给你,只有这么点了。 展开
展开全部
无限级分类的主要内容:
建一个栏目表,如
栏目ID,栏目名称,父栏目ID,父栏目名称,栏目深度,栏目管理员
用递归可以得出每一级栏目的名称及其父栏目名称。代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%'if session("login") <> "yes" then response.Redirect "login.asp"%>
<!--#include file="conn.asp"-->
<%
sub popup(str,url)
response.write "<script language='javascript'>" & chr(13)
response.write "alert('"&str&"!');" & Chr(13)
response.write "window.document.location.href='"&url&"';"&Chr(13)
response.write "</script>" & Chr(13)
response.End()
end sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>栏目管理</title>
<link href="admin.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
function CheckForm()
{
if (document.form.lan_name.value.length == 0) {
alert("请输入栏目名称!");
document.form.lan_name.focus();
return false;
}
}
//-->
</script>
<style type="text/css">
<!--
body {
background-color: #C1D6EA;
}
-->
</style></head>
<%
'递归调用函数,生成一个类别代码
sub reclass(id)
set rs=server.createobject("adodb.recordset")
sql="select * from lan where fu_id="&id
rs.open sql,conn,1,1
while not rs.eof
lan_id0 = rs("lan_id")
lan_name0 = rs("lan_name")
fu_name0 = rs("fu_name")
fu_id0 = rs("fu_id")
level0 = rs("lan_level")
brstr = ""
for j=1 to level0
brstr=" "&brstr
next
'if user_right(session("user_name"),lan_id0)="yes" or session("level")="管理员" then
%>
<tr class="altbg2" onMouseOver="this.className='altbg1'" onmouseout="this.className='altbg2'">
<td width="7%" align="center"><%=lan_id0%></td>
<td width="30%"><%=brstr%>└<%=lan_name0%></td>
<td width="15%" align="center"><%=fu_name0%></td>
<td width="23%" align="center"><a href="lanmu_modify.asp?lan_id=<%=lan_id0%>&lan_name=<%=lan_name0%>"><font color="#008000">修改</font></a> <%'if session("level")="管理员" then%><a href="lanmu_admin.asp?lan_id=<%=lan_id0%>&lan_name=<%=lan_name0%>">增加子栏目</a> <a href="lanmu_del.asp?lan_id=<%=lan_id0%>&lan_name=<%=lan_name0%>"><font color="#FF0000">删除</font></a><%'end if%></td>
</tr>
<%
'end if
call reclass(lan_id0)
rs.movenext
wend
rs.close
set rs=nothing
end sub
%>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="23%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12" colspan="2" bgcolor="#799ae1"></td>
</tr>
<tr>
<td height="25" bgcolor="#1F58C8" class="bt1"> <strong>栏目管理 首页</strong></td>
<td width="114" bgcolor="#1F58C8"><img src="img/title1.gif" width="114" height="25" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#E4E4E4"> </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<!------栏目管理首页,即栏目管理的默认页面------>
<% If request("act") = "" Then %>
<%If request("lan_id")="" Then%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<form id="form" name="form" method="post" action="lanmu_admin.asp?act=add&fu_name=无" onsubmit="return CheckForm()">
<tr>
<td width="100" align="right" bgcolor="#FFFFFF"><strong>栏目名称:</strong></td>
<td bgcolor="#FFFFFF"><input name="lan_name" type="text" id="lan_name" size="16"></td>
<td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="添加一级栏目"></td>
</tr>
</form>
</table>
<br />
<%end if
If request("lan_id")<>"" then
%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<form id="form" name="form" method="post" action="lanmu_admin.asp?act=add&fu_id=<%=request("lan_id")%>&fu_name=<%=request("lan_name")%>" onsubmit="return CheckForm()">
<tr>
<td width="100" align="right" bgcolor="#FFFFFF"><strong>栏目名称:</strong></td>
<td bgcolor="#FFFFFF"><input name="lan_name" type="text" id="lan_name" size="16"></td>
<td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="在【<%=request("lan_name")%>】中添加子栏目"></td>
</tr>
</form>
</table>
<br />
<%end if%>
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from lan where fu_id=0 order by lan_id"
rs1.open sql1,conn,1,1
if rs1.eof or rs1.bof then
%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<tr>
<td bgcolor="#FFFFFF"><font color="#FF0000">没有栏目</font></td>
</tr>
</table>
<%else%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<tr>
<td width="7%" align="center" bgcolor="#FFFFFF"><strong>栏目ID</strong></td>
<td width="30%" align="center" bgcolor="#FFFFFF"><strong>栏目名称</strong></td>
<td width="15%" align="center" bgcolor="#FFFFFF"><strong>父栏目名称</strong></td>
<td width="23%" align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
<%
while not rs1.eof
lan_id1 = rs1("lan_id")
lan_name1 = rs1("lan_name")
fu_name1 = rs1("fu_name")
fu_id1 = rs1("fu_id")
'if user_right(session("user_name"),lan_id1)="yes" or session("level")="管理员" then
%>
<tr class="altbg2" onMouseOver="this.className='altbg1'" onmouseout="this.className='altbg2'">
<td align="center"><%=lan_id1%></td>
<td><%=lan_name1%></td>
<td align="center">无</td>
<td align="center"><a href="lanmu_admin.asp?act=modify&lan_id=<%=lan_id1%>&lan_name=<%=lan_name1%>"><font color="#008000">修改</font></a> <%'if session("level")="管理员" then%><a href="lanmu_admin.asp?lan_id=<%=lan_id1%>&lan_name=<%=lan_name1%>">增加子栏目</a> <a href="lanmu_admin.asp?act=del&lan_id=<%=lan_id1%>&lan_name=<%=lan_name1%>"><font color="#FF0000">删除</font></a><%'end if%></td>
</tr>
<%
'end if
call reclass(lan_id1)
rs1.movenext
wend
end if
rs1.close
set rs1=nothing
%>
</table>
<% End If %>
<!------栏目管理--栏目修改页面------>
<% If request("act") = "modify" Then %>
<% End If %>
<!--栏目管理--栏目修改保存页面-->
<% If request("act") = "modify_save" Then %>
<% End If %>
<!------栏目管理--栏目删除确认页面------>
<% If request("act") = "del" Then %>
<% End If %>
<!------栏目管理--栏目删除执行页面------>
<% If request("act") = "del_ok" Then %>
<% End If %>
<!--栏目管理--增加新栏目-->
<% If request("act") = "add" Then %>
<%
if request("fu_name")="无" then
set rs = server.CreateObject("adodb.recordset")
sql = "select * from lan where lan_name='"&request("lan_name")&"'"
rs.open sql,conn,3,3
if not rs.eof then
call popup("已存在相同栏目名称,请更换",Request.ServerVariables("HTTP_REFERER"))
else
rs.addnew
rs("lan_name") = request("lan_name")
rs("fu_name") = "无"
rs("fu_id") = 0
rs("lan_level") = 0
rs.update
call popup("栏目添加成功!","lanmu_admin.asp")
end if
rs.close
set rs = nothing
else
set rs = server.CreateObject("adodb.recordset")
sql = "select * from lan where lan_name='"&request("lan_name")&"' and fu_name='"&request("fu_name")&"'"
rs.open sql,conn,3,3
if not rs.eof then
call popup("已存在相同栏目名称,请更换",Request.ServerVariables("HTTP_REFERER"))
else
set rsa = server.createobject("adodb.recordset")
sqla = "select * from lan where lan_id = "&request("fu_id")&" and lan_name = '"&request("fu_name")&"'"
rsa.open sqla,conn,1,1
rsa_level = rsa("lan_level")
rsa.close
set rsa = nothing
rs.addnew
rs("lan_name") = request("lan_name")
rs("fu_name") = request("fu_name")
rs("fu_id") = request("fu_id")
rs("lan_level") = rsa_level+1
rs.update
call popup("栏目添加成功!","lanmu_admin.asp")
end if
rs.close
set rs = nothing
end if
%>
<% End If %>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#E4E4E4"> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<%
conn.close
set conn = nothing
%>
建一个栏目表,如
栏目ID,栏目名称,父栏目ID,父栏目名称,栏目深度,栏目管理员
用递归可以得出每一级栏目的名称及其父栏目名称。代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%'if session("login") <> "yes" then response.Redirect "login.asp"%>
<!--#include file="conn.asp"-->
<%
sub popup(str,url)
response.write "<script language='javascript'>" & chr(13)
response.write "alert('"&str&"!');" & Chr(13)
response.write "window.document.location.href='"&url&"';"&Chr(13)
response.write "</script>" & Chr(13)
response.End()
end sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>栏目管理</title>
<link href="admin.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
function CheckForm()
{
if (document.form.lan_name.value.length == 0) {
alert("请输入栏目名称!");
document.form.lan_name.focus();
return false;
}
}
//-->
</script>
<style type="text/css">
<!--
body {
background-color: #C1D6EA;
}
-->
</style></head>
<%
'递归调用函数,生成一个类别代码
sub reclass(id)
set rs=server.createobject("adodb.recordset")
sql="select * from lan where fu_id="&id
rs.open sql,conn,1,1
while not rs.eof
lan_id0 = rs("lan_id")
lan_name0 = rs("lan_name")
fu_name0 = rs("fu_name")
fu_id0 = rs("fu_id")
level0 = rs("lan_level")
brstr = ""
for j=1 to level0
brstr=" "&brstr
next
'if user_right(session("user_name"),lan_id0)="yes" or session("level")="管理员" then
%>
<tr class="altbg2" onMouseOver="this.className='altbg1'" onmouseout="this.className='altbg2'">
<td width="7%" align="center"><%=lan_id0%></td>
<td width="30%"><%=brstr%>└<%=lan_name0%></td>
<td width="15%" align="center"><%=fu_name0%></td>
<td width="23%" align="center"><a href="lanmu_modify.asp?lan_id=<%=lan_id0%>&lan_name=<%=lan_name0%>"><font color="#008000">修改</font></a> <%'if session("level")="管理员" then%><a href="lanmu_admin.asp?lan_id=<%=lan_id0%>&lan_name=<%=lan_name0%>">增加子栏目</a> <a href="lanmu_del.asp?lan_id=<%=lan_id0%>&lan_name=<%=lan_name0%>"><font color="#FF0000">删除</font></a><%'end if%></td>
</tr>
<%
'end if
call reclass(lan_id0)
rs.movenext
wend
rs.close
set rs=nothing
end sub
%>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="23%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12" colspan="2" bgcolor="#799ae1"></td>
</tr>
<tr>
<td height="25" bgcolor="#1F58C8" class="bt1"> <strong>栏目管理 首页</strong></td>
<td width="114" bgcolor="#1F58C8"><img src="img/title1.gif" width="114" height="25" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#E4E4E4"> </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<!------栏目管理首页,即栏目管理的默认页面------>
<% If request("act") = "" Then %>
<%If request("lan_id")="" Then%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<form id="form" name="form" method="post" action="lanmu_admin.asp?act=add&fu_name=无" onsubmit="return CheckForm()">
<tr>
<td width="100" align="right" bgcolor="#FFFFFF"><strong>栏目名称:</strong></td>
<td bgcolor="#FFFFFF"><input name="lan_name" type="text" id="lan_name" size="16"></td>
<td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="添加一级栏目"></td>
</tr>
</form>
</table>
<br />
<%end if
If request("lan_id")<>"" then
%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<form id="form" name="form" method="post" action="lanmu_admin.asp?act=add&fu_id=<%=request("lan_id")%>&fu_name=<%=request("lan_name")%>" onsubmit="return CheckForm()">
<tr>
<td width="100" align="right" bgcolor="#FFFFFF"><strong>栏目名称:</strong></td>
<td bgcolor="#FFFFFF"><input name="lan_name" type="text" id="lan_name" size="16"></td>
<td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="在【<%=request("lan_name")%>】中添加子栏目"></td>
</tr>
</form>
</table>
<br />
<%end if%>
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from lan where fu_id=0 order by lan_id"
rs1.open sql1,conn,1,1
if rs1.eof or rs1.bof then
%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<tr>
<td bgcolor="#FFFFFF"><font color="#FF0000">没有栏目</font></td>
</tr>
</table>
<%else%>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#799AE1">
<tr>
<td width="7%" align="center" bgcolor="#FFFFFF"><strong>栏目ID</strong></td>
<td width="30%" align="center" bgcolor="#FFFFFF"><strong>栏目名称</strong></td>
<td width="15%" align="center" bgcolor="#FFFFFF"><strong>父栏目名称</strong></td>
<td width="23%" align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
<%
while not rs1.eof
lan_id1 = rs1("lan_id")
lan_name1 = rs1("lan_name")
fu_name1 = rs1("fu_name")
fu_id1 = rs1("fu_id")
'if user_right(session("user_name"),lan_id1)="yes" or session("level")="管理员" then
%>
<tr class="altbg2" onMouseOver="this.className='altbg1'" onmouseout="this.className='altbg2'">
<td align="center"><%=lan_id1%></td>
<td><%=lan_name1%></td>
<td align="center">无</td>
<td align="center"><a href="lanmu_admin.asp?act=modify&lan_id=<%=lan_id1%>&lan_name=<%=lan_name1%>"><font color="#008000">修改</font></a> <%'if session("level")="管理员" then%><a href="lanmu_admin.asp?lan_id=<%=lan_id1%>&lan_name=<%=lan_name1%>">增加子栏目</a> <a href="lanmu_admin.asp?act=del&lan_id=<%=lan_id1%>&lan_name=<%=lan_name1%>"><font color="#FF0000">删除</font></a><%'end if%></td>
</tr>
<%
'end if
call reclass(lan_id1)
rs1.movenext
wend
end if
rs1.close
set rs1=nothing
%>
</table>
<% End If %>
<!------栏目管理--栏目修改页面------>
<% If request("act") = "modify" Then %>
<% End If %>
<!--栏目管理--栏目修改保存页面-->
<% If request("act") = "modify_save" Then %>
<% End If %>
<!------栏目管理--栏目删除确认页面------>
<% If request("act") = "del" Then %>
<% End If %>
<!------栏目管理--栏目删除执行页面------>
<% If request("act") = "del_ok" Then %>
<% End If %>
<!--栏目管理--增加新栏目-->
<% If request("act") = "add" Then %>
<%
if request("fu_name")="无" then
set rs = server.CreateObject("adodb.recordset")
sql = "select * from lan where lan_name='"&request("lan_name")&"'"
rs.open sql,conn,3,3
if not rs.eof then
call popup("已存在相同栏目名称,请更换",Request.ServerVariables("HTTP_REFERER"))
else
rs.addnew
rs("lan_name") = request("lan_name")
rs("fu_name") = "无"
rs("fu_id") = 0
rs("lan_level") = 0
rs.update
call popup("栏目添加成功!","lanmu_admin.asp")
end if
rs.close
set rs = nothing
else
set rs = server.CreateObject("adodb.recordset")
sql = "select * from lan where lan_name='"&request("lan_name")&"' and fu_name='"&request("fu_name")&"'"
rs.open sql,conn,3,3
if not rs.eof then
call popup("已存在相同栏目名称,请更换",Request.ServerVariables("HTTP_REFERER"))
else
set rsa = server.createobject("adodb.recordset")
sqla = "select * from lan where lan_id = "&request("fu_id")&" and lan_name = '"&request("fu_name")&"'"
rsa.open sqla,conn,1,1
rsa_level = rsa("lan_level")
rsa.close
set rsa = nothing
rs.addnew
rs("lan_name") = request("lan_name")
rs("fu_name") = request("fu_name")
rs("fu_id") = request("fu_id")
rs("lan_level") = rsa_level+1
rs.update
call popup("栏目添加成功!","lanmu_admin.asp")
end if
rs.close
set rs = nothing
end if
%>
<% End If %>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#E4E4E4"> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<%
conn.close
set conn = nothing
%>
参考资料: http://www.loveagle.com
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询