asp 分页函数,可以显示 1,2,3,4,5... 前十页,后十页,下一页,上一页
发布时间:2009-07-05 18:34:00
<%
SoFia_DbName="jiaoyou" '修改此处为你的SQL Server 数据库名称
YourServer = "seven" '修改此处为你的Sql Server数据库地址
YourUid = "sa" '修改此处为你的数据库用户名
YourPassword = "struts" '修改此处为你的数据库密码
Connstr = "Driver={SQL Server};Server="&YourServer&";Uid="&YourUid&";
Pwd="&YourPassword&";Database="&SoFia_DbName
Set Conn=Server.CreateObject("ADODB.CONNECTION")
' On Error Resume Next
Conn.Open Connstr
If Err<>0 Then
err.Clear
Set Conn = Nothing
Response.Write "<div align=center><br><br><br>连接SqlServer数据库出错,请检查相关设置……</div>"
Response.End
End If
set rs = server.CreateObject("adodb.recordset")
rs.open "select * from userInfo order by id desc",conn,1,1
if not(rs.Eof and rs.Bof) Then
page = trim(request.form("page"))
if page = "" then page = trim(request.QueryString("page"))
if Not(IsNumeric(page)) or page = "0" then page = 1
rs.pageSize = 30 '设置每页的个数
strFile = "?" '设置当前页面的名称
pageCount = rs.pageCount
if len(page) > 4 then page = pageCount
if Cint(page) > Cint(pageCount) then page = pageCount
rs.absolutepage = page
for i = 1 to rs.pagesize
if rs.eof then exit for
Response.Write (Rs("username")&"<br>")&VbNewline
rs.MoveNext
Next'i
End if%>
<%
Response.Write ("<table border=0 align=center cellpadding=0 cellspacing=0><tr><td>")&VbNewline
if pagecount < 1 then pagecount = 1
response.Write ("第"&page&"页/共"&PAGECOUNT&"页,每页"&rs.pageSize&"条/共"&rs.recordCount&"条记录</td><td> ")
beginpage = 1
endpage = CInt(pagecount)
page = CInt(page)
if pagecount >= 9 then
if page >= 5 then
beginpage = page - 4
if page <= (pagecount - 4) then
endpage = page + 4
else
endpage = pagecount
beginpage = pagecount - 4
end if
else
beginpage = 1
endpage = 9
end if
end if
if beginpage>1 then response.write "<a title=首页 href='"&strFile&logpage&"'><font face=webdings>9</font></a>"
for j = beginpage to endpage
if j = page then
response.write"[<b>"&j&"</b>] "
else
response.write"[<a href='"&strFile&"page="&j&logpage&"'>"&j&"</a>] "
end if
next
if endpage < pagecount then response.write ("<a title=末页 href='"&strFile&"page="&pagecount&logpage&"'><font face=webdings>:</font></a>")
Response.Write ("</td><form name='changepage' method='post' action='"&strFile&"'><td align='right'> ")&VbNewline
Response.Write ("<select name='page' onchange='document.changepage.submit();'>")&VbNewline
For i=0 To pagecount
If i<>pagecount Then
Response.Write ("<option value='"&i+1&"'")
If page=i+1 Then Response.Write (" selected")
Response.Write (">"&i+1&"</option>")&VbNewline
End If
Next
Response.Write ("</select></td></form></tr></table>")
rs.close
set rs = nothing
%>
方法二:
<!--#include file="conn.asp"-->
<%
dim ip
ip=Request.ServerVariables("REMOTE_ADDR")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css.css" rel="stylesheet" type="text/css">
<title>LCD软件管理系统 全部软件</title>
<script language="JavaScript">
function deletes()
{
if( confirm("你确定要删除这些文件吗?\n"))
{return true;
}
return false;
}
</script>
</head>
<body leftmargin="0" topmargin=5>
<center>
<h3><font color=red face="幼圆">全部软件列表</font></h3>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from info where used=0 and pn<>'0' order by pn"
rs.open sql,conn,1,1
%>
<table width="870" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" class=text>
<tr><td colspan="6">
共有:<font size=2 color=red><b> <%=rs.recordcount%> </b></font><font size=2>个软件</font>
<%
MMaxPerPage=15
rs.PageSize=MMaxPerPage
if trim(request("Page"))<>"" then
CurrentPage=CInt(request("Page"))
if CurrentPage>rs.PageCount then
CurrentPage=rs.PageCount
end if
else
CurrentPage=1
end if
ttotalPut=rs.RecordCount
if CurrentPage<>1 then
if (CurrentPage-1)*MMaxPerPage<ttotalPut then
rs.Move(CurrentPage-1)*MMaxPerPage
bookmark=rs.Bookmark
end if
end if
if (ttotalPut mod MMaxPerPage)=0 then
mm=ttotalPut\MMaxPerPage
else
mm=ttotalPut\MMaxPerPage+1
end if
if (ttotalPut mod (MMaxPerPage*10))=0 then
nn=ttotalPut\(MMaxPerPage*10)
else
nn=ttotalPut\(MMaxPerPage*10)+1
end if
%>
<%
if (CurrentPage mod 10)=0 then
kk=CurrentPage\10-1
else
kk=CurrentPage\10
end if
if nn>1 and CurrentPage>10 then
Response.Write "<b><a href='all.asp?s1="&request("s1")&"&s2="&request("s2")&"&s3="&request("s3")&"&s4="&request("s4")&"&andor="&request("andor")&"&ss="&request("ss")&"&page="+CStr((kk-1)*10+1)+"'>Pre.</a></b>"
end if
for ii=1 to 10
jj=kk*10+ii
if jj<=mm then
if jj=CurrentPage then
Response.Write " <font color=red>"+CStr(jj)+"</font>"
else
Response.Write " <b>"+"<a href='all.asp?s1="&request("s1")&"&s2="&request("s2")&"&s3="&request("s3")&"&s4="&request("s4")&"&andor="&request("andor")&"&ss="&request("ss")&"&page="+CStr(jj)+"'>"+CStr(jj)+"</a></b>"
end if
end if
next
Response.Write " "
if kk<nn-1 then
Response.Write " <b>"+"<a href='all.asp?s1="&request("s1")&"&s2="&request("s2")&"&s3="&request("s3")&"&s4="&request("s4")&"&andor="&request("andor")&"&ss="&request("ss")&"&page="+CStr((kk+1)*10+1)+"'>Next</a></b>"
end if
%></td></tr></table>
<table width="870" border=0 cellpadding=0 cellspacing=0 class=text>
<tr>
<td width=30>ID</td>
<td width=110>料号</td>
<td width=190>显示屏</td>
<td width=100>主板</td>
<td width=180>语言</td>
<td width=110>LOGO</td>
<td width=50>版本</td>
<td width=60>文件大小</td>
<td width=40> </td>
</tr>
<tr height="1" bgcolor="#689ACE"><td colspan="9"></td></tr>
<%
k=0
for y=(page-1)*15+1 to (page-1)*15+15
do while not rs.EOF and i<MMaxPerPage
%>
<tr <%if i mod 2 then%> bgcolor=#DEE3F7 <%End if%> height=25>
<td width=30>
<%
Set Fs = Server.CreateObject("Scripting.FileSystemObject")
If Fs.FileExists(server.mappath("uploadfile/"&rs("filepath"))) Then
Response.Write "<font color=gray>"&rs("id")&"</font>"
else
Response.Write "<font color=red>"&rs("id")&"</font>"
end if
%></td>
<td width=110><%=rs("pn")%></td>
<%set rs1=server.createobject("adodb.recordset")
sql1="select * from item where id="&rs("panel")
rs1.open sql1,conn,1,1%>
<td width=190><%=rs1("item")%></td>
<%set rs1=server.createobject("adodb.recordset")
sql1="select * from item where id="&rs("mb")
rs1.open sql1,conn,1,1%>
<td width=100><%=rs1("item")%></td>
<%set rs1=server.createobject("adodb.recordset")
sql1="select * from item where id="&rs("lang")
rs1.open sql1,conn,1,1%>
<td width=180><%=rs1("item")%></td>
<td width=110><%If IsNumeric(Left(rs("logo"),8)) then%><img src="LogoFile/<%=rs("logo")%>" width=100 border=0 vspace="1"><%else%><%=rs("logo")%><%End if%></td>
<td width=50><%=rs("vers")%></td>
<td width=60><%=Round(rs("filesize")/1024,2)%> K</td>
<td width=40><a href=# onclick=openwin('list.asp?id=<%=rs("id")%>')>详细</a></td>
</tr>
<%
i=i+1
rs.MoveNext
loop
next
%>
<tr height="1" bgcolor="#689ACE"><td colspan="9"></td></tr>
</table>
</body>
</html>


猜你喜欢
- 提高SQL执行效率的几点建议:◆尽量不要在where中包含子查询;关于时间的查询,尽量不要写成:where to_char(dif_date
- 在大的互联网公司干技术的基本都会碰到测试、预发布、线上这种多套环境的,来实现测试和线上正式环境的隔离,这种情况下,就难免会碰到秀逗了把测试的
- 本文实例讲述了php文件上传类。分享给大家供大家参考,具体如下:/**$file=new class_file($file_array,&q
- 关于英文的写作有一本十分著名的书,The Elements of Style(风格要素),编写程序也有一本The Elements of P
- UUID 全称是 Universally unique identifier,它是一种识别符,使用任意的计算机都可以生成,不需要一个中央数据
- 一、正常配置stylus流程1.安装stylus、stylus-loader依赖(进入项目文件夹下)cnpm install stylus
- 经常有一些图像任务需要从一张大图中截取固定大小的patch来进行训练。这里面常常存在下面几个问题:patch的位置尽可能随机,不然数据丰富性
- 配置说明Linux系统:CentOS-7.0MySQL版本:5.7.21Linux系统下启动多个MySQL实例,目前知道有两种方法,一种是通
- 在Netbeans中由于使用了Swing进行开发,所以其中界面的字体也是由Java虚拟机进行配置而不是随操作系统的。在安装完Netbeans
- 方法一、尽量使用复杂的SQL来代替简单的一堆 SQL.同样的事务,一个复杂的SQL完成的效率高于一堆简单SQL完成的效率。有多个查询时,要善
- 本文实例讲述了Python编程判断这天是这一年第几天的方法。分享给大家供大家参考,具体如下:题目:输入某年某月某日,判断这一天是这一年的第几
- 如下所示:1.条件判断2.内置函数abs()3.内置模块 math.fabsabs() 与fabs()的区别abs()是一个内置函数,而fa
- 在sql语句后使用 SCOPE_IDENTITY() 当然您也可以使用 SELECT @@IDENTITY 但是使用 SELECT @@ID
- 一、Oracle分析函数简介:在日常的生产环境中,我们接触得比较多的是OLTP系统(即Online Transaction Process)
- “深入认识Python内建类型”这部分的内容会从源码角度为大家介绍Python中各种常用的内建类型。
- 通过锁机制,可以实现多线程同时对某个表进行操作。如下图所示,在某个时刻,用户甲、用户乙、用户丙可能会同时或者先后(前面一个作业还没有完成)对
- 安装wgetyum -y install wget创建一个download目录用于下载各种安装包mkdir download切换到刚创建的d
- 在asp中利用excel的一个方法是将excel文件作为一个数据库进行链接,然后的操作和对access数据库操作类似.但是这个方法不是总能有
- 问题你的程序获取了一个目录中的文件名列表,但是当它试着去打印文件名的时候程序崩溃, 出现了 UnicodeEncodeError 异常和一条
- 1.检查重复元素下面的方法可以检查给定列表中是否有重复的元素。它使用了 set() 属性,该属性将会从列表中删除重复的元素。def all_