大家帮我挑挑错!先谢了。(100分)

  • 主题发起人 主题发起人 mzyang
  • 开始时间 开始时间
M

mzyang

Unregistered / Unconfirmed
GUEST, unregistred user!
在主页中采用下面的方法调用数据库内的文章
<script language="javascript" src="news.asp?typeid=1&amp;n=5"></script>
想要达到显示typeid=1的栏目的头5条文章题目的目的,现运行后文章题目可以正常显示,
但题目条数的限制数n却没有作用,显示的是typeid=1栏目的所有文章题目。这是为何?
下面是news.asp:
<!--#include file="function/DBOpen.asp"-->
str="<style>A:link{text-decoration:none;color:black}A:visited{text-decoration:none;color:black}A:active{text-decoration:none}A:hover{text-decoration:underline;color:red}</style><table width=100% border=0 cellpadding=0 cellspacing=0>"
<%
function invert(str)
invert=replace(replace(replace(replace(str,"&amp;lt;","<"),"&amp;gt;",">"),"<br>",""),"&amp;nbsp;"," ")
end function
kind=request("kind")
typeid=request("typeid")
borderid=request("borderid")
n=trim(request("n"))
n=int(n)
if n="" or IsNumeric(n)=false then
n=7
end if
set rs=server.createobject("adodb.recordset")
if kind="img" then
if typeid="" or IsNumeric(typeid)=false then
sql="select top 1 * from news where imgsize<>0 and audit=1 order by ntime DESC"
else
sql="select top 1 * from news where typeid=" &amp;
cstr(typeid) &amp;
" and imgsize<>0 and audit=1 order by ntime DESC"
end if
end if
if kind="hot" then
if typeid="" or IsNumeric(typeid)=false then
sql="select top " &amp;
n &amp;
" * from news where audit=1 order by hits DESC"
else
sql="select top " &amp;
n &amp;
" * from news where typeid=" &amp;
cstr(typeid) &amp;
" and audit=1 order by hits DESC"
end if
end if
if kind="" then
if typeid="" or IsNumeric(typeid)=false then
if borderid="" or IsNumeric(borderid)=false then
sql="select top " &amp;
n &amp;
" * from news where audit=1 order by ntime DESC"
else
sql="select top " &amp;
n &amp;
" * from news where borderid=" &amp;
cstr(borderid) &amp;
" and audit=1 order by ntime DESC"
end if
else
if borderid="" or IsNumeric(borderid)=false then
sql="select top " &amp;
n &amp;
" * from news where typeid=" &amp;
cstr(typeid) &amp;
" and audit=1 order by ntime DESC"
else
sql="select top " &amp;
n &amp;
" * from news where typeid=" &amp;
cstr(typeid) &amp;
" and borderid=" &amp;
cstr(borderid) &amp;
" and audit=1 order by ntime DESC"
end if
end if
end if
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
if kind="img" then
%>
str=str + "<tr><td valign=/"Middle/" align=/"center/" width=45%><a href='shownews.asp?newsid=<%=rs("newsid")%>' target=_blank><img src='showimg.asp?newsid=<%=rs("newsid")%>' border=0 width=110 height=81 alt='<%=trim(rs("topic"))%>'><br><%=rs("topic")%></a></td></tr>"
<%else
%>
str=str + "<tr><td width=100% align=left>"
<%do
while not rs.eof %>
str=str+"<li type=circle><a href=/"shownews.asp?newsid=<%=rs("newsid")%>/" target=_blank><%if cstr(rs("imgsize")) <>0 then
%><font color=/"#FF0400/" font size=/"1/">[图文]</font><%end if%><%=trim(rs("topic"))%></a><font color=/"#6365CE/" font size=/"1/">(<%theday=cstr(YEAR(rs("ntime")))&amp;"-"&amp;cstr(MONTH(rs("ntime")))&amp;"-"&amp;cstr(DAY(rs("ntime")))
response.write theday%>)</font><%if month(cdate(trim(rs("ntime"))))=month(now()) and clng(day(cdate(trim(rs("ntime"))))+1)>=clng(day(now())) then
%><img src=images/news.gif><%end if%>"
<% rs.movenext
loop %>
str=str + "</td></tr>"
<% end if
end if
rs.close
set rs=nothing
%>
str=str+ "</table>"
document.write (str)
<!--#include file="function/DBclose.asp"-->
 
for i=1 to n
rs.movenext
if rs.eof then
exit for
next
 
感谢xusong168,问题解决?但用SQL为什么不对呢?恳请分析后相告。
 
我看不出来,你用的是sql server 2000吗?
 
一个小问题,为何要用那么蚂蟥的蚂蟥来解决?
 
接受答案了.
 

Similar threads

I
回复
0
查看
843
import
I
I
回复
0
查看
687
import
I
I
回复
0
查看
589
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
1K
import
I
后退
顶部