asp分页显示时单引号引发的一个错误!

本文由newsoftstudio.com
iuprg撰写

<%
bclassid=trim(request("bclassid"))

word    =trim(request("word"))

sql= "select * from bnews where BnewsCheck=1 and bnewstitle<>'' "

  sql=sql&" and (BnewsClass='"&bclassid&"')" 

if tj="1" then
   sql= sql & " and tj='推荐' "
end if
if hot="1" then
  sql=sql & " order by bnewshit desc , bnewsid desc"
else
  sql=sql & " order by bnewsontop desc , bnewsid desc"
end if
%>
<div align="center">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
  
<%
Set Newsrs = Server.CreateObject("ADODB.RecordSet")
Newsrs.Open sql,conn,1,1

if Newsrs.recordcount<>0 then

page=int(request.QueryString ("page"))
Newsrs.PageSize=listnum
pagecount=newsrs.pagesize

if page<=0 then page=1
if request.QueryString("page")="" then page=1
newsrs.AbsolutePage=page

for i=1 to pagecount
   
    %>
    <tr>
   <td align=left>
    <%
        
        bclassid=newsrs("bnewsclass")
         sql2 = "select * from bclassinfo where bclassid="&bclassid
         Set rs2 = Server.CreateObject("ADODB.RecordSet")
         rs2.Open sql2,conn,1,1
         Mybclassname=rs2("bclassname")    ' by drs  2006-6-5
         
      if newsrs("bnewstitlecolor")="默认颜色" or newsrs("bnewstitlecolor")="" then
        fontcolor="999999"
      else
        fontcolor=newsrs("bnewstitlecolor")
      end if

    %>
      <%=icon%><%if bclassname="1" then response.write "[<a href=bsnews_showNewsMore.asp?bclassid="&rs2("bclassid")&">"&mybclassname&"</a>]&nbsp;"%><a href="bsnews_newsdisplay.asp?newsid=<%=newsrs("bnewsid")%>" <%=openwindow%>><font color="<%=trim(bnewsfontcolor)%>"><%=titleb(newsrs("bnewstitle"),titleLen)%></font></a>
      <font color=999999>
      <%
  if newshit="1" then response.write "阅读:"&newsrs("bnewshit")
                if trim(newsrs("bnewspic"))<>"" then Response.Write "[图]"
      %>
      </td><td>
      <%
     
         MyMonth= month(newsrs("bnewsdate"))      'by drs 2006-7-28 日期显示 为 [06-28] 颜色为6d6d6d
         MyDay  = day(newsrs("bnewsdate"))
         if cint(MyMonth)<10 then MyMonth="0"&MyMonth
         if cint(MyDay  )<10 then MyDay  ="0"&MyDay 
 
          if newstime=1 then response.write "<font color=6d6d6d >["&formatdatetime(newsrs("bnewsdate"),1)&"]</font>"
          if newstime=2 then response.write "<font color=6d6d6d >["&formatdatetime(newsrs("bnewsdate"),2)&"]</font>"
          if newstime=3 then response.write "<font color=6d6d6d >["&month(newsrs("bnewsdate"))&"月"&day(newsrs("bnewsdate"))&"日]</font>"
          if newstime=4 then response.write "<font color=999999 >["&MyMonth&"-"&MyDay&"]</font>"
     
        'if newstime="1" then response.write "("&formatdatetime(rs("bnewsdate"),1)&")"
      %>
      </font>
      </td></tr>
    <%
    newsrs.movenext
    if newsrs.eof then exit for
 
 next
 
else
  response.write "<center><BR><BR><BR>请输入相关信息后才能正确显示此内容:)<BR><BR><BR><BR>"
end if
%>
</table><BR><center>
<%
if newsrs.recordcount<>0 then
  if page>1 then%>
     <a href='<%=request.servervariables("URL")%>?page=1&word=<%=word%>&bclassid=<%=trim(request("bclassid"))%>&bclassname=<%=trim(request("bclassname"))%>&isopen=<%=trim(request("isopen"))%>&titleLen=<%=trim(request("titleLen"))%>&hot=<%=trim(request("hot"))%>&tj=<%=trim(request("tj"))%>'>首页</a>
     <a href='<%=request.servervariables("URL")%>?page=<%=page-1%>&word=<%=word%>&bclassid=<%=trim(request("bclassid"))%>&bclassname=<%=trim(request("bclassname"))%>&isopen=<%=trim(request("isopen"))%>&titleLen=<%=trim(request("titleLen"))%>&hot=<%=trim(request("hot"))%>&tj=<%=trim(request("tj"))%>'>上一页</a>
  <%end if%>
  <%if page<newsrs.pagecount then%>
     <a href='<%=request.servervariables("URL")%>?page=<%=page+1%>&word=<%=word%>&bclassid=<%=trim(request("bclassid"))%>&bclassname=<%=trim(request("bclassname"))%>&isopen=<%=trim(request("isopen"))%>&titleLen=<%=trim(request("titleLen"))%>&hot=<%=trim(request("hot"))%>&tj=<%=trim(request("tj"))%>'>下一页</a>
     <a href='<%=request.servervariables("URL")%>?page=<%=newsrs.pagecount%>&word=<%=word%>&bclassid=<%=trim(request("bclassid"))%>&bclassname=<%=trim(request("bclassname"))%>&isopen=<%=trim(request("isopen"))%>&titleLen=<%=trim(request("titleLen"))%>&hot=<%=trim(request("hot"))%>&tj=<%=trim(request("tj"))%>'>尾页</a>
  <%end if%>
 共<%=newsrs.recordcount%>条 每页显示<%=pagecount%>条  第<%=page%>页 共<%=newsrs.pagecount%>页    
    <script language="JavaScript">
      <!--
       function FP_jumpMenu(el,frm,sel) {//v1.0
       var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
       if('_new'==frm) open(href); else eval(frm+".location='"+href+"'");
        }
       // -->
     </script>

   <select size="1" οnchange="FP_jumpMenu(this,'window',false)" id="id1" name="D1" style="font-size: 9pt; border-style: solid; border-width: 1px">
        <%for i=1 to newsrs.pagecount%>
          <option value="<%=request.servervariables("URL")%>?page=<%=i%>&word=<%=word%>&bclassid=<%=trim(request("bclassid"))%>&bclassname=<%=trim(request("bclassname"))%>&isopen=<%=trim(request("isopen"))%>&titleLen=<%=trim(request("titleLen"))%>&hot=<%=trim(request("hot"))%>&tj=<%=trim(request("tj"))%>>" <%if page=i then response.write "selected"%>>第<%=i%>页</option>
        <%next%>
    </select>
</p>
<%end if%><%
end function
%> 

 ====本文由http://www.newsoftstudio.com  iuprg撰写===

显示更多新闻的代码,每页10条,由于修改疏忽

if newstime=4 then response.write "<font color=999999 '>["&MyMonth&"-"&MyDay&"]</font>"

999999后面多了一个 ' 单引号,却造成每页只显示5条的错误,至今也没想明白为什么?!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安优小青和他的程序生活

我的文档对您有很大的帮助吗?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值