ASP分类显示问题。C表有N(名称)SID(产铺ID)PID(分类ID)PID为0时是大类,其它为小类,怎么样与代码 5
1个回答
展开全部
假设数据库连接为conn,应该还需要一个ID,不然没法对应上子类
set bs=server.createobject("adodb.recordset") ----定义主类数据集对象
set ss=server.createobject("adbdo.recordset") -----定义子类数据集对象
bs.open "select * from [C] where PID=0",conn,1,1
if bs.eof and bs.bof then
response.write "暂无主分类"
else
do while no bs.eof
response.write "<h3>" & bs("N") &"</h3>"
response.write "<ul>"
ss.open "select * from [C] where PID=" & bs("ID")
if ss.eof and ss.bof then
response.write "暂无子类"
else
do while not ss.eof
response.write "<li><a href='show.asp?id=" & ss("ID") & "'>"*& ss("N") &"</a></li>"
ss.movenext
loop
end if
response.write "</ul>"
loop
end if
set bs=server.createobject("adodb.recordset") ----定义主类数据集对象
set ss=server.createobject("adbdo.recordset") -----定义子类数据集对象
bs.open "select * from [C] where PID=0",conn,1,1
if bs.eof and bs.bof then
response.write "暂无主分类"
else
do while no bs.eof
response.write "<h3>" & bs("N") &"</h3>"
response.write "<ul>"
ss.open "select * from [C] where PID=" & bs("ID")
if ss.eof and ss.bof then
response.write "暂无子类"
else
do while not ss.eof
response.write "<li><a href='show.asp?id=" & ss("ID") & "'>"*& ss("N") &"</a></li>"
ss.movenext
loop
end if
response.write "</ul>"
loop
end if
追问
没办法两次打开同一张表。我做出了片代码,你能帮我改一下吗,对象打开时不允许操作。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询