<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-CN" />
<meta content="all" name="robots" />
<title>24款实用的翻页页码css代码 - 80IT工作室</title>
<link rel="stylesheet" type="text/css" href="http://localhost/css/fy.css" media="all" />
</head>
<body>
<p>　</p>

<p>Gray Style

<div class="quotes"><span class="disabled"> 上一页 </span>

<span class="current">1</span>
<a href="#?page=2">2</a>
<a href="#?page=3">3</a>
<a href="#?page=4">4</a>
<a href="#?page=5">5</a>
<a href="#?page=6">6</a>
<a href="#?page=7">7</a>...
<a href="#?page=199">199</a>
<a href="#?page=200">200</a>

<a href="#?page=2"> 下一页 </a>
</div>

</p>
<br /><br />
</p>
</body>
</html>

<%
'+++++++++++++++++++++++++++++++++++++
'◆模块名称： 公共翻页模块
'◆文 件 名： TurnPage.asp
'◆传入参数： Rs_tmp (记录集), PageSize (每页显示的记录条数)
'◆输 出： 记录集翻页显示功能
'+++++++++++++++++++++++++++++++++++++
'
Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 记录集 ; PageSize 每页显示的记录条数;
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转；
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页，则默认显示第一页；
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If
'获取当前文件名，使得每次翻页都在当前页面进行；
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称，使翻页的链接指向当前文件；
fileName = Mid(fileName,postion)
%>
<table border=0 width='100%'>
<tr>
<td align=left> 总页数：<font color=#ff3333><%=TotalPage%></font>页
当前第<font color=#ff3333><%=PageNo%></font>页</td>
<td align="right">
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "首页|前页|后页|末页"
Else%>
<a href="<%=fileName%>?PageNo=1">首页|</a>
<%If PageNo - 1 = 0 Then
Response.Write "前页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">前页|</a>
<%End If
If PageNo+1 > TotalPage Then
Response.Write "后页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">后页|</a>
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末页</a>
<%End If%></td>
<td width=95>转到第
<%If TotalPage = 1 Then%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%>
<input type=text name=PageNo size=3 value="" title=请输入页号,然后回车>
<%End If%>页
</td>
</tr>
</table>
<%End Sub%>
　　当然，大家可以把翻页的链接做成图片按钮，这样的话也面就更加美观了。
　　调用方法:
　　1、在程序开始或要使用翻页的地方包含翻页模块文件；
　　2、定义变量：RowCount，每页显示的记录条数
　　3、调用翻页过程：Call TurnPage(记录集,RowCount)
　　4、在Do While 循环输出记录集的条件中加上" RowCount > 0 " 条件
　　5、在循环结束 "Loop前" 加上： RowCount = RowCount - 1
'-----------------------------------------------------
调用范例：
文件名：News.asp
<%
Dim Conn，Rs_News
Set Conn = server.CreateObject("ADODB.CONNECTION")
Conn.Open "cpm","cpm","cpm"
Dim Sql
Sql = "Select * from News"
Set Rs_News = Server.CreateObject("ADODB.RECORDSET")
Rs_News.Open Sql,Conn,1,3 '获取的记录集
'公共翻页模块开始%>
<!--#include file=../Public/TurnPage.asp-->
<%
Dim RowCount
RowCount = 10 '每页显示的记录条数
Call TurnPage(Rs_News,RowCount)
'公共翻页模块结束%>
<table width=100%>
<tr>
<td>新闻编号</td>
<td>新闻标题</td>
<td>发布日期</td>
<tr>
<%
If Not Rs_News.eof
Do while Not Rs_News.eof and RowCount>0
%>
<tr>
<td><%=Rs_News("ID")%></td>
<td><%=Rs_News("Name")%></td>
<td><%=Rs_News("Date")%></td>
<tr>
<%
RowCount = RowCount - 1
Rs_News.MoveNext
Loop
End If
%>


  <%@   page   contentType="text/html;charset=gb2312"%>   
  <%@   page   isErrorPage="true"%>   
  <%@   page   errorPage="er.jsp"%>   
  <%@   page   import="java.sql.*"%>   
  <%@include   file="dbcon.jsp"%>   
  <%   
  Connection   DBcon=DriverManager.getConnection(url);   
  java.sql.Statement   sqlStmt;//sql语句对象   
  java.sql.ResultSet   sqlRst;//结果集对象   
  java.lang.String   strSQL;//sql语句   
  int   intPageSize;//一页显示的记录集   
  int   intRowCount;//记录集总数   
  int   intPageCount;//总页数   
  int   intPage;//待显示页码   
  java.lang.String   strPage;   
  int   i;   
  intPageSize=25;//设置一页显示的记录数   
  strPage=request.getParameter("page");   
  if(strPage==null)   
  {//表明在querstring中没有page这一个参数，此时显示第一页数据   
  intPage=1;   
  }   
  else   
  {//将字符串转换成整数   
  strPage=strPage.trim();   
  intPage=java.lang.Integer.parseInt(strPage);   
  if(intPage<1)   
  intPage=1;   
  }   
  sqlStmt=DBcon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);   
    
  %>   
    
    
    
  <html>   
  <head>   
  <title>邮院新闻网</title>   
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
  <script   language="JavaScript"   type="text/JavaScript">   
  <!--   
  function   MM_openBrWindow(theURL,winName,features)   {   //v2.0   
      window.open(theURL,winName,features);   
  }   
  //-->   
  </script>   
  <style   type="text/css">   
  <!--   
  body,td,th   {   
  font-size:   12px;   
  }   
  body   {   
  margin-left:   0px;   
  margin-top:   0px;   
  margin-right:   0px;   
  margin-bottom:   0px;   
  }   
  .king1   {   
    FONT-SIZE:   8pt;     FONT-FAMILY:   "Verdana",   "Arial",   "Helvetica",   "sans-serif";   HEIGHT:   16px;     
  }   
  .bar1   {   
  BORDER-RIGHT:   #959595   1px   solid;   PADDING-RIGHT:   0px;   BORDER-TOP:   #959595   1px   solid;   PADDING-LEFT:   0px;   FONT-SIZE:   9pt;   PADDING-BOTTOM:   0px;   BORDER-LEFT:   #959595   1px   solid;   COLOR:   #000000;   PADDING-TOP:   0px;   BORDER-BOTTOM:   #959595   1px   solid;   FONT-FAMILY:   "Verdana",   "Arial",   "Helvetica",   "sans-serif";   HEIGHT:   18px;   BACKGROUND-COLOR:   #e5e5e5;   TEXT-DECORATION:   none   
  }   
  a.more:link   {     font-size:   16px;   color:   #00165E;   text-decoration:   none}   
  a.more:visited   {     font-size:   16px;   color:   #00165E;   text-decoration:   none}   
  a.more:active   {     font-size:   16px;   color:   #00165E;   text-decoration:   none}   
  a.more:hover   {     font-size:   16px;   color:   #666666;   text-decoration:   underline}   
  .time   {     font-size:   12px;   color:   #0066CC}   
  .main_downlinepit   {     background-image:   url(image/pit.GIF);   background-repeat:   repeat-x;   background-position:   bottom;   line-height:   22px}   
  a:link   {   
  color:   #000000;   
  text-decoration:   none;   
  }   
  a:visited   {   
  text-decoration:   none;   
  color:   #000000;   
  }   
  a:hover   {   
  text-decoration:   underline;   
  color:   #333333;   
  }   
  a:active   {   
  text-decoration:   none;   
  color:   #000000;   
  }   
  -->   
  </style>   
  </head>   
    
  <body   class="whitetext"   bgcolor="#FFFFFF">   
  <table   width="779"   border="0"   align="center"   cellpadding="0"   cellspacing="0"     ><tbody>   
      <!--DWLayoutTable-->   
      <tr   valign="middle"   bgcolor="#004379">     
          <td   height="13"   colspan="6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img   src="image/top.jpg"   width="106"   height="10"   align="absmiddle"></td>   
      </tr>   
      <tr   valign="middle"   bgcolor="#2fa2ff">     
          <td   height="23"   colspan="6"   class="whitetext">     
              <div   align="right"><a   href="#">首页</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">学校概况</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">双师工程</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">培训中心</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">技能鉴定</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">继续教育</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">招生就业</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">图书馆</a>&nbsp;&nbsp;</div>   
          </td>   
      </tr>   
      <tr   valign="middle"   bgcolor="#6E6E6E">     
          <td   height="26"   colspan="3"   valign="middle"   bgcolor="#BBE0FF"   >&nbsp;&nbsp;<a   href="#">新闻空间</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">热点新闻</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">重要新闻</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a   href="#">科室新闻</a></td>   
            <form   name="form1"   method="get"   action="find.jsp">   
  <td   colspan="2"   valign="middle"   bgcolor="#BBE0FF">   
    
              <input   type="text"   name="find"   class=king1>   
      <input   type=image   src="image/search.jpg"   value="Reset"   align="middle">   
              </td>   
      </form></td>   
      </tr>   
      <tr>     
          <td   height="60"   colspan="6"   valign="top"><object   classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"   width="779"   height="60">   
                  <param   name="movie"   value="flash/logo.swf">   
                  <param   name="quality"   value="high">   
                  <embed   src="flash/logo.swf"   quality="high"   pluginspage="http://www.macromedia.com/go/getflashplayer"   type="application/x-shockwave-flash"   width="779"   height="60">   
                  </embed>     
              </object></td>   
      </tr>   
      <tr>     
          <td   width="28"   rowspan="5"   valign="top">&nbsp;   </td>   
          <td   height="125"   valign="top"   colspan="4">     
              <table   width="100%"   border="0"   cellpadding="0"   cellspacing="0">   
                  <tr>     
                      <td   width="602"   height="125"   align="right"><img   src="image/more/lgvideo.jpg"   width="174"   height="35"></td>   
                      <td   width="119"   valign="top">     
                          <table   width="100%"   border="0"   cellpadding="0"   cellspacing="0">   
                              <tr>     
                                  <td   width="118"   height="125"   bgcolor="#000000"></td>   
                              </tr>   
                          </table>   
                      </td>   
                  </tr>   
              </table>   
          </td>   
          <td   width="30"   rowspan="5"   valign="top">&nbsp;   </td>   
      </tr>   
	  
	  
	  
	  <%language="vbscript"
set conn=server.createobject("adodb.connection")
conn.open "driver={sql server};server=luo;uid=sa;pwd=;database=zszl"
set rs=server.createobject("adodb.recordset")%>
<%pgsize=5
page=request.querystring("page")
sql="select * from test where id1=1"
rs.open sql,conn,1
rs.pagesize=pgsize
pgnm=rs.pagecount
if page=""or clng(page)<1 then page=1
if clng(page)>pgnm then page=pgnm
if pgnm>0 then rs.absolutepage=page
count=0
do while not rs.eof and count<rs.pagesize 
%><%=rs("id1")%><br>
<%=d%><br>
<%count=count+1
rs.movenext
loop
rs.close
set rs=nothing
%>
<a href=dis.asp?page=1>第一页</a>
<a href=dis.asp?page=<%=pgnm%>>最后一页</a>
<a href=dis.asp?page=<%=page+1%>>下一页</a>
<a href=dis.asp?page=<%=page-1%>>上一页</a> 
