ASP 一个页面执行 无线分类问题
<divid="menu"><h1><ahref="admin_eyes.asp?tianjia=ok">请添加眼镜栏目</a></h1><divid="news"><d...
<div id="menu"><h1><a href="admin_eyes.asp?tianjia=ok">请添加眼镜栏目</a></h1>
<div id="news">
<dl>
<%
set rs=server.CreateObject("adodb.recordset")
sql = "select * from eyes where eyes_classid = 0 order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write ""
else
do while not rs.eof
'format_i=format_i+1
%>
<dt><%=rs("id")%></dt><dt><%=rs("eyes_name")%></dt><dt><a href="admin_eyes.asp?add=tianzi&eyesid=<%=rs("eyes_classid")%>&id=<%=rs("id")%>" >添加子分类</a> <a href="admin_eyes.asp?add=xiugai&id=<%=rs("id")%>" >修改</a> <a href="#"><a href="admin_eyes.asp?add=sanchu&id=<%=rs("id")%>" onclick='return confirm("真的要删除吗?删除之后将无法恢复");'>删除</a></dt>
<%
dim rs2,sql2
set rs2=server.CreateObject("adodb.recordset")
sql2 = "select * from eyes where eyes_classid ="&rs("id")
rs2.open sql2,conn,1,1
response.Write sql2&"<br/>"
response.Write rs2("eyes_classid")&"<br/>"
response.Write rs2("id")&"<br/>"
do while not rs2.eof
%>
<dd><%
'for i=format_i to 3 step -1
'response.wrITe "|-"
'response.wrITe " "
'next
'response.wrITe "|-"
%><%=rs2("id")%></dd><dd><%=rs2("eyes_name")%></dd><dd><a href="admin_eyes.asp?add=tianzi&eyesid=<%=rs2("eyes_classid")%>&id=<%=rs2("id")%>" >添加子分类</a> <a href="admin_eyes.asp?add=xiugai&id=<%=rs2("id")%>" >修改</a> <a href="#"><a href="admin_eyes.asp?add=sanchu&id=<%=rs2("id")%>" onclick='return confirm("真的要删除吗?删除之后将无法恢复");'>删除</a></dd>
<%rs2.movenext
loop
%>
<%
rs.movenext
loop
call Close.rs
end if
response.end()
%>
</dl>
</div></div>
只能得到 eyes_classid = 0 下的 id 值
所以只能实现 二级分类 和 添加.
求高人改下 指点下,菜鸟就别瞎说了. 展开
<div id="news">
<dl>
<%
set rs=server.CreateObject("adodb.recordset")
sql = "select * from eyes where eyes_classid = 0 order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write ""
else
do while not rs.eof
'format_i=format_i+1
%>
<dt><%=rs("id")%></dt><dt><%=rs("eyes_name")%></dt><dt><a href="admin_eyes.asp?add=tianzi&eyesid=<%=rs("eyes_classid")%>&id=<%=rs("id")%>" >添加子分类</a> <a href="admin_eyes.asp?add=xiugai&id=<%=rs("id")%>" >修改</a> <a href="#"><a href="admin_eyes.asp?add=sanchu&id=<%=rs("id")%>" onclick='return confirm("真的要删除吗?删除之后将无法恢复");'>删除</a></dt>
<%
dim rs2,sql2
set rs2=server.CreateObject("adodb.recordset")
sql2 = "select * from eyes where eyes_classid ="&rs("id")
rs2.open sql2,conn,1,1
response.Write sql2&"<br/>"
response.Write rs2("eyes_classid")&"<br/>"
response.Write rs2("id")&"<br/>"
do while not rs2.eof
%>
<dd><%
'for i=format_i to 3 step -1
'response.wrITe "|-"
'response.wrITe " "
'next
'response.wrITe "|-"
%><%=rs2("id")%></dd><dd><%=rs2("eyes_name")%></dd><dd><a href="admin_eyes.asp?add=tianzi&eyesid=<%=rs2("eyes_classid")%>&id=<%=rs2("id")%>" >添加子分类</a> <a href="admin_eyes.asp?add=xiugai&id=<%=rs2("id")%>" >修改</a> <a href="#"><a href="admin_eyes.asp?add=sanchu&id=<%=rs2("id")%>" onclick='return confirm("真的要删除吗?删除之后将无法恢复");'>删除</a></dd>
<%rs2.movenext
loop
%>
<%
rs.movenext
loop
call Close.rs
end if
response.end()
%>
</dl>
</div></div>
只能得到 eyes_classid = 0 下的 id 值
所以只能实现 二级分类 和 添加.
求高人改下 指点下,菜鸟就别瞎说了. 展开
4个回答
展开全部
给你一个无限级分类下拉的函数例子,跟你的要求是相同原理的,要用到递归的
数据库结构是
id title TID1
'sel_Name 下拉菜单名称
'sel_selected 默认选中值
'iTableName 数据表名
'ifloor 初始层数 - 1
'iTID1 初始父级ID - 0
'sel_valField value值对应的字段名
'sel_TextField text 值对就的字段名
function createSelect(sel_Name, sel_selected , iTableName , ifloor, iTID1, sel_valField,sel_TextField)
if ifloor = "" then ifloor = 1
if iTID1 = "" then iTID1 = 0
if sel_valField = "" then sel_valField = "id"
if sel_TextField = "" then sel_TextField = "title"
if ifloor = 1 then
selectStr = selectStr&"<select name='"&sel_Name&"' id='"&sel_Name&"'>"&VbCrLf
end if
ifloorStr = ""
for i=1 to int(ifloor-1)
ifloorStr = ifloorStr&" "
next
sql = "select * from "&iTableName&" where TID1 = "&iTID1&" order by orderid"
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
do while not rs.eof
iChecked = ""
if sel_selected = sel_valField then iChecked = "selected"
sql2 = "select * from "&iTableName&" where TID1 = "&rs("id")
set rs2 = server.CreateObject("ADODB.recordset")
rs2.open sql2,conn,1,1
Vcount = rs2.recordcount
rs2.close
set rs2 = nothing
if Vcount <> 0 then
selectStr = selectStr&"<optgroup label="""&ifloorStr&"├"&rs(sel_TextField)&"--("&ifloor&"级)""></optgroup>"&VbCrLf
selectStr = selectStr&createSelect(sel_Name, sel_selected, iTableName, int(ifloor + 1), rs("id"),sel_valField,sel_TextField)
else
selectStr = selectStr&"<option value='"&rs(sel_valField)&"' "&iChecked&">"&ifloorStr&"├"&rs(sel_TextField)&"--("&ifloor&"级)</option>"&VbCrLf
end if
rs.movenext
loop
rs.close
set rs = nothing
if ifloor = 1 then
selectStr = selectStr&"</select>"&VbCrLf
end if
createSelect = selectStr
end function
数据库结构是
id title TID1
'sel_Name 下拉菜单名称
'sel_selected 默认选中值
'iTableName 数据表名
'ifloor 初始层数 - 1
'iTID1 初始父级ID - 0
'sel_valField value值对应的字段名
'sel_TextField text 值对就的字段名
function createSelect(sel_Name, sel_selected , iTableName , ifloor, iTID1, sel_valField,sel_TextField)
if ifloor = "" then ifloor = 1
if iTID1 = "" then iTID1 = 0
if sel_valField = "" then sel_valField = "id"
if sel_TextField = "" then sel_TextField = "title"
if ifloor = 1 then
selectStr = selectStr&"<select name='"&sel_Name&"' id='"&sel_Name&"'>"&VbCrLf
end if
ifloorStr = ""
for i=1 to int(ifloor-1)
ifloorStr = ifloorStr&" "
next
sql = "select * from "&iTableName&" where TID1 = "&iTID1&" order by orderid"
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
do while not rs.eof
iChecked = ""
if sel_selected = sel_valField then iChecked = "selected"
sql2 = "select * from "&iTableName&" where TID1 = "&rs("id")
set rs2 = server.CreateObject("ADODB.recordset")
rs2.open sql2,conn,1,1
Vcount = rs2.recordcount
rs2.close
set rs2 = nothing
if Vcount <> 0 then
selectStr = selectStr&"<optgroup label="""&ifloorStr&"├"&rs(sel_TextField)&"--("&ifloor&"级)""></optgroup>"&VbCrLf
selectStr = selectStr&createSelect(sel_Name, sel_selected, iTableName, int(ifloor + 1), rs("id"),sel_valField,sel_TextField)
else
selectStr = selectStr&"<option value='"&rs(sel_valField)&"' "&iChecked&">"&ifloorStr&"├"&rs(sel_TextField)&"--("&ifloor&"级)</option>"&VbCrLf
end if
rs.movenext
loop
rs.close
set rs = nothing
if ifloor = 1 then
selectStr = selectStr&"</select>"&VbCrLf
end if
createSelect = selectStr
end function
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
展开全部
你的sql语句就限制eyes_classid = 0
一种是所有的类别都在同张表,字段有上级id,所有下级id,级别路径==
比较复杂。
你自己到网站搜下,有很多
一种是所有的类别都在同张表,字段有上级id,所有下级id,级别路径==
比较复杂。
你自己到网站搜下,有很多
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不是太明白你的意思,类别的ID可以根据你的链接传过来,你看看你的数据库表结构里面的多级类别是自己设置的!有什么不明白的加我HI或者把文件发给我,我帮你看看!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
留个邮箱,给你发个比较好用的无限极分类代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询