asp语法问题

ziyuanxian 2009-06-07 12:09:48
<%
small =rsSmallClass("SmallClassName")
if small<>"" then
sqlt = "select count(*),id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
If count==1 then
%>
<A href="show.asp?id=<%=rst("id")%>"><%=rsSmallClass("SmallClassName")%></A>
<% else
response.write "没有记录."
end if
if rst.state<>0 then rst.close
set rst = nothing
else%>
<a href="1otype.asp?classid=<%=rst("bigclassid")%>&boardname=<%=rsSmallClass("SmallClassName")%>">
<%
end if

%>

我这个是一个关于栏目里记录数多少判断后跟据数目不同分别链到不同的页面。
即记录为1时,让它直接链到这个记录的内容显示页,否则链到记录的列表页。
上面是我弄的代码,实现不了我要的功能。
望高手们指点一下,谢谢啦!
...全文
42 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
anbs01 2009-06-08
  • 打赏
  • 举报
回复
这个对。
[Quote=引用 6 楼 wushaowu 的回复:]
<%
sqlt = "select id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
if not rst.eof and not rst.bof then
If rst.count=1 then
'连接到单独页面显示
else
'连接到列表页面显示

[/Quote]
银狐被占用 2009-06-08
  • 打赏
  • 举报
回复
6楼的方法就可以
lihan6415151528 2009-06-07
  • 打赏
  • 举报
回复

<%
small =rsSmallClass("SmallClassName")
if small<>"" then
sqlt = "select count(*),id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
If not rst.bof and rst.eof %>
<A href="show.asp?id=<%=rst("id")%>"><%=rsSmallClass("SmallClassName")%></A>
<% else
response.write "没有记录."
end if
if rst.state<>0 then rst.close
set rst = nothing
else%>
<a href="1otype.asp?classid=<%=rst("bigclassid")%>&boardname=<%=rsSmallClass("SmallClassName")%>">
<%
end if

%>
lzp4881 2009-06-07
  • 打赏
  • 举报
回复
<%
small =rsSmallClass("SmallClassName")
if small <>"" then
sqlt = "select count(*) as count,id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
If rst("count")=1 then
%>
<A href="show.asp?id= <%=rst("id")%>"> <%=rsSmallClass("SmallClassName")%> </A>
<% else
response.write "没有记录."
end if
if rst.state <>0 then rst.close
set rst = nothing
else%>
<a href="1otype.asp?classid= <%=rst("bigclassid")%>&boardname= <%=rsSmallClass("SmallClassName")%>">
<%
end if

%>
lzp4881 2009-06-07
  • 打赏
  • 举报
回复
<%
small =rsSmallClass("SmallClassName")
if small<>"" then
sqlt = "select count(*),id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
If rst("count")=1 then
%>
<A href="show.asp?id=<%=rst("id")%>"><%=rsSmallClass("SmallClassName")%></A>
<% else
response.write "没有记录."
end if
if rst.state<>0 then rst.close
set rst = nothing
else%>
<a href="1otype.asp?classid=<%=rst("bigclassid")%>&boardname=<%=rsSmallClass("SmallClassName")%>">
<%
end if

%>
wushaowu 2009-06-07
  • 打赏
  • 举报
回复
<%
sqlt = "select id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
if not rst.eof and not rst.bof then
If rst.count=1 then
'连接到单独页面显示
else
'连接到列表页面显示
end if
else
response.write "没有记录."
end if
rst.close
set rst = nothing
%>
ziyuanxian 2009-06-07
  • 打赏
  • 举报
回复
3楼也是一样
ziyuanxian 2009-06-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lzp4881 的回复:]
<%
small =rsSmallClass("SmallClassName")
if small <>"" then
sqlt = "select count(*) as count,id from news where SmallClassName='" & small&"'"
set rst = server.createobject("adodb.recordset")
rst.open sqlt,conn,1,1
If rst("count")=1 then
%>
<A href="show.asp?id= <%=rst("id")…
[/Quote]
用了这个后,所用的链接都变成了http://127.0.0.1/show.asp?id=
我输出了一下count,发现是空的,什么都没有

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧