回 帖 发 新 帖 刷新版面

主题:求助:一下代码如何修改

下面的代码该怎么加上   判断记录为空时,显示“暂无信息”这几个字,应该加到哪个地方,谢谢,菜鸟才开始接触,见笑了~~~~


<table border="0" cellpadding="0" cellspacing="0" width="680" align="center">
          <tr> 
            <td align="center" valign="top" width="580" colspan="2"> 
              <% '=============打开数据库表,要以这种方式打开   
set rs=server.CreateObject("adodb.recordset")  
rs.open "select id,title,laiyuan,content,time,hit,titlecolorfrom [News] where lm='73' order by id desc",conn,1,1
%>
              <%'=============分页定义开始,要放在数据库打开之后
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if not (rs.eof and rs.bof) then '检测记录集是否为空
r=cint(rs.RecordCount) '记录总数
rowcount = 30 '设置每一页的数据记录数,可根据实际自定义
rs.pagesize = rowcount '分页记录集每页显示记录数
maxpagecount=rs.pagecount '分页页数
page=request.querystring("page")
  if page="" then
  page=1
  end if
rs.absolutepage = page 
rcount1=0
pagestart=page-9
pageend=page+9
if pagestart<1 then
pagestart=1
end if
if pageend>maxpagecount then
pageend=maxpagecount
end if
rcount=rs.RecordCount
'=============分页定义结束%>
              <table width="680" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td> 
                    <%'===========循环体开始
do while not rs.eof and rowcount%>
                    <table width="680" border="0" align="center" cellpadding="2" cellspacing="0">
                      <tr <%if icolor=0 then response.write"bgColor=#f9f9f9" else response.write"bgColor=#ffffff" end if%>> 
                        <td width="580" height="30"> 
                          <div align="left"> · <a href=/news_view.asp?newsid=<%=rs("id")%> target="_blank" title="<%=left(rs("title"),60)%><% if len(rs("title"))>=60 then%> …<%end if%>"> 
                            <%=left(rs("title"),50)%> 
                            <% if len(rs("title"))>=50 then%>
                            … 
                            <%end if%>
                            </a></div></td>
                        <td width="100"><%=formatdatetime(rs("time"),2)%></td>
                      </tr>
                    </table>
                    <%
rowcount=rowcount-1 
rs.movenext
icolor=icolor+1
if icolor>1 then icolor=0
loop
end if
end if
 '===========循环体结束%>
                  </td>
                </tr>
              </table>
              <%'===========显示分页的过程调用,要放在数据库打开后、释放资源前
call listPages()  
rs.close  '释放资源
set rs=nothing%>
              <%'==========分页过程开始,也可单独创建一文件在本文件前包含调用
 sub listPages() '定义过程开始%>
              <form method=bPost action=110.asp>
              </form></td>
          </tr>
          <tr  align="left"> 
            <td  bgcolor=#E4E4E4  > 
              <%if pagestart=1 then%>
              <FONT face=webdings><span style="color: #FF0000">&nbsp;&nbsp;9</span></font> 
              <%else%>
              <a href=110.asp?page=1 title="首页"><FONT
 face=webdings><span >9</span></font></a> 
              <%end if%>
              <% for i=pagestart to pageend
            if i=0 then 
            i=1
            end if
            strurl="<a href=110.asp?page="&i&" title='到"&i&"页'>"&i&"</a>"
response.write strurl
response.write " "
 next
            %>
              <%if pageend=maxpagecount then%>
              <FONT
 face=webdings><span style="color: #FF0000">:</span></font> 
              <%else%>
              <a href=110.asp?page=<%=maxpagecount%> title="尾页"><FONT
 face=webdings><span >:</span></font></a> 
              <%end if%>
              &nbsp;&nbsp; 页次:<font color=red><%=page%></font>/<%=maxpagecount%>页 
        </table>
        <%end sub '定义过程结束
'==========分页过程结束%>

回复列表 (共2个回复)

沙发


 <% '=============打开数据库表,要以这种方式打开   
set rs=server.CreateObject("adodb.recordset")  
rs.open "select id,title,laiyuan,content,time,hit,titlecolorfrom [News] where lm='73' order by id desc",conn,1,1
[color=0000FF]if rs.bof and rs.eof then
   response.write"暂无信息"
   response.end
end if[/color]%>

板凳


这样是可以了,不过代码是不是还有其它问题,页面的其他地方不显示了,能帮我看看吗?如果没有数据,页面的右面部分也不显示了

我来回复

您尚未登录,请登录后再回复。点此登录或注册