分页代码

来源:互联网 发布:iphone7移动数据几百kb 编辑:程序博客网 时间:2024/05/17 01:41
 
<!--#include file="conn.asp"-->
<%
N_type
=request("N_type")


set rs = server.createobject("adodb.recordset")

sql 
= "select * from news"
if N_type<>"" then sql=sql&" where N_type='"&N_type&"'"
sql
=sql&" order by N_id desc"
rs.Open SQL, Conn, 
11
rs.pagesize
=20
PageNo
=request("PageNo")

if request("PageNo")="" then PageNo=1
totalpages
=rs.pagecount
if request.servervariables("content_length"> 0 then
    currentpage
=1
else
    currentpage
=clng(PageNo)
end if
if currentpage>totalpages then currentpage=totalpages 
if not(rs.eof) then rs.absolutepage = currentpage
%
>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻列表</title>
<LINK href="rsc.css" type=text/css rel=stylesheet>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  
<tr>
    
<td>
      
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
        
<tr bgcolor="#E3E8F9"> 
          
<td height="15" bgcolor="#E3E8F9"> 
            
<div align="center"><font size="2"><strong>项 目 标 题</strong></font></div></td>
          
<td width="80" height="18"> 
            
<div align="center"><font size="2"><strong>项目类型</strong></font></div></td>
          
<td width="120" height="18"> 
            
<div align="center"><font size="2"><strong>管理</strong></font></div></td>
        
</tr>
        
<%
rowcount
=(currentpage - 1)*rs.pagesize
for i=1 to rs.pagesize
    
if rs.eof then exit for
        %
>
        
<tr bgcolor="#F4F8FF"> 
          
<td height="20" title="<%=rs("N_time")%>"><a href="shownews.asp?N_id=<%=rs("N_id")%>" target=_blank><%if rs("N_hot")=true then response.write "<font color=red>"%><%=left(rs("N_title"),22)%> 
            
<%if len(rs("N_title"))>22 then response.write "……"%><%if rs("N_pic")<>"" then%>[图]<%end if%>
            
</a></td>
          
<td> <div align="center"><a href="?N_type=<%=rs("n_type")%>"><%=rs("n_type")%></a></div></td>
          
<td> 
            
<div align="center"> 
<%if session("userlimit")>0 then%>
              
<%if rs("N_enabled")=false then%>
              
<a href="enablednews.asp?N_id=<%=rs("N_id")%>&pageno=<%=PageNo%>"><font color=green>通过</font></a> 
              
<%else%>
              
<a href="enablednews.asp?N_id=<%=rs("N_id")%>&pageno=<%=PageNo%>"><font color=red>取消</font></a> 
              
<%end if%>
<%end if%>
<%if session("userlimit")>0 or (session("userlimit")<1 and rs("N_enabled")=false)then%>&nbsp;&nbsp;<a href="editnews.asp?N_id=<%=rs("N_id")%>&pageno=<%=PageNo%>">修改</a><%end if%>
<%if session("userlimit")>0 then%>&nbsp;&nbsp;<a href="javascript:if(confirm('您确定要删除此条信息?')) window.location.href='delnews.asp?N_id=<%=rs("N_id")%>&pageno=<%=PageNo%>'">删除</a><%end if%>
        
</div>
        
</td>        
        
</tr>
        
<%
    rs.movenext
next                 
%
>
      
</table>
      
    
</td>
  
</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  
<tr>
    
<td height="20" bgcolor="#E3E8F9"> 
      
<div align="center"> 
        
<%if currentpage>1 then%>
        
<a href="?N_type=<%=N_type%>&pageno=1"> 〖首页〗</a>&nbsp;&nbsp;<a href="?N_type=<%=N_type%>&pageno=<%=currentpage-1%>">〖上一页〗</a>&nbsp;&nbsp; 
        
<%end if                       
                
if currentpage < totalpages then%>
        
<a href="?N_type=<%=N_type%>&pageno=<%=currentpage+1%>">〖下一页〗</a>&nbsp;&nbsp;<a href="?N_type=<%=N_type%>&pageno=<%=totalpages%>">〖尾页〗</a> 
        
<%end if%>
        
&nbsp; 本页是第 <%=currentpage%>/<%=totalpages%> 页 共&nbsp;<%=rs.recordcount%>&nbsp;条 
        转到第
      
<select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;">
      
<%
       
for i = 1 to rs.PageCount
       
if i = currentpage then%>
       
<option value="?N_type=<%=N_type%>&pageno=<%=i%>" selected><%=i%></option>
      
<%else%>
       
<option value="?N_type=<%=N_type%>&pageno=<%=i%>"><%=i%></option>
      
<%
      
end if
      
next
      %
>
     
</select>
      
</div>    
    
</td>
  
</tr>
</table>
</body>
</html>