回 帖 发 新 帖 刷新版面

主题:[讨论]如何给文章自动加上编号(不读数据库)


<table width="670" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="top"> 
      <%set rs=server.createobject("adodb.recordset")
            rs.open "select id,title from News where lm='10' order by id desc",conn,1,1
        if rs.recordcount=0 then 
        %>
      <table width="370" border="0" cellspacing="0" cellpadding="5" align="center">
        <tr> 
          <td align=center>暂无内容</td>
        </tr>
      </table>
      <%
        else
              rs.PageSize =12 '每页记录条数
            iCount=rs.RecordCount '记录总数
            iPageSize=rs.PageSize
            maxpage=rs.PageCount 
            page=request("page")
    
    if Not IsNumeric(page) or page="" then
        page=1
    else
        page=cint(page)
    end if
    
    if page<1 then
        page=1
    elseif  page>maxpage then
        page=maxpage
    end if
    
    rs.AbsolutePage=Page

    if page=maxpage then
        x=iCount-(maxpage-1)*iPageSize
    else
        x=iPageSize
    end if
    

        %>
      <table width="95%"  border="0" cellspacing="0" cellpadding="8" align="center">
        <tr> 
          <%
                ii=0
                
                For i=1 To x
        %>
          <TD width=340 align=center bgcolor="#FFFFFF"> <div align="left"> <a href=/news_view.asp?newsid=<%=rs("id")%> target="_blank" > 
              <%=left(rs("title"),19)%> 
              </a> </div></td>
          <%rs.movenext
             ii=ii+1%>
          <%if ii mod 2 =0 then%>
        </tr>
        <tr> 
          <%end if%>
          <% next%>
        </tr>
      </table>
      <%
        call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
        end if
        rs.close
        set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
    Dim query, a, x, temp
    action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

    query = Split(Request.ServerVariables("QUERY_STRING"), "&")
    For Each x In query
        a = Split(x, "=")
        If StrComp(a(0), "page", vbTextCompare) <> 0 Then
            temp = temp & a(0) & "=" & a(1) & "&"
        End If
    Next

    Response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0 >" & vbCrLf )        
    Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR >" & vbCrLf )
    Response.Write("<TD align=center height=35>" & vbCrLf )
    Response.Write(font_style & vbCrLf )    
        
    if page<=1 then
        Response.Write ("首 页 " & vbCrLf)        
        Response.Write ("上一页 " & vbCrLf)
    else        
        Response.Write("<A HREF=" & action & "?" & temp & "Page=1><font color=000000>首 页</font></A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & "><font color=000000>上一页</font></A> " & vbCrLf)
    end if

    if page>=pagecount then
        Response.Write ("下一页 " & vbCrLf)
        Response.Write ("尾 页 " & vbCrLf)            
    else
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & "><font color=000000>下一页</font></A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & "><font color=000000>尾 页</font></A> " & vbCrLf)            
    end if

    Response.Write(" 页次:" & page & "/" & pageCount & "页" &  vbCrLf)
    Response.Write(" 共有" & iCount & "条信息" &  vbCrLf)
    Response.Write(" 转到" & "<INPUT  TYEP=TEXT NAME=page SIZE=2 Maxlength=5 VALUE=" & page & ">" & "页"  & vbCrLf & "<INPUT  type=submit value=GO>")
    Response.Write("</TD>" & vbCrLf )                
    Response.Write("</TR></form>" & vbCrLf )        
    Response.Write("</table>" & vbCrLf )        
End Sub
%>
    </td>
  </tr>
</table>


就像下面的样式


(1)、我是初学者请多多指教               (2)、我是初学者请多多指教 

(3)、我是初学者请多多指教               (4)、我是初学者请多多指教 

(5)、我是初学者请多多指教               (6)、我是初学者请多多指教 

(7)、我是初学者请多多指教               (8)、我是初学者请多多指教

回复列表 (共2个回复)

沙发


 <table width="95%"  border="0" cellspacing="0" cellpadding="8" align="center">
        <tr> 
          <%
                ii=0
                [color=FF0000]dim m
                m=(page-1)*iPageSize      [/color]    
                For i=1 To x
                [color=0000FF]m=m+1[/color]
        %>
          <TD width=340 align=center bgcolor="#FFFFFF"> <div align="left"><%
[color=FF0000]response.write"("& m &")"[/color]
%> <a href=/news_view.asp?newsid=<%=rs("id")%> target="_blank" > 
              <%=left(rs("title"),19)%> 
              </a> </div></td>
          <%rs.movenext
             ii=ii+1%>
          <%if ii mod 2 =0 then%>
        </tr>
        <tr> 
          <%end if%>
          <% next%>
        </tr>
      </table>

板凳

太棒了,谢谢

我来回复

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