标签:des style http color java 使用 os io
<%
Option Explicit
‘Response.Flush
Dim BeginTime,EndTime
BeginTime=Timer
Dim conn,SQLstr,Rs,DefRecordNum,CursorBegin,CursorEnd,CurPageNum,hav
DefRecordNum=5
‘--------------获取相关参数----------
If Request("CursorBegin")="" Then CursorBegin=0 Else CursorBegin=Request("CursorBegin")
If Request("CursorEnd")="" Then CursorEnd=0 Else CursorEnd=Request("CursorEnd")
If Request("CurPageNum")<>"" Then
CurPageNum=CLng(Request("CurPageNum"))
If CurPageNum<=0 Then CurPageNum=1
Else
CurPageNum=1
End If
hav=Request("hav")
If hav="" Then hav="next"
‘----------------End-----------------
‘------------显示翻页内容函数--------
Function TurnPageFS(DispRecordNum)
Dim n
While Not(Rs.Eof) And n<DispRecordNum
n=n+1
Response.Write "<tr>"&_
"<td bgcolor=’efefef’>"&Rs(0)&"</td>"&_
"<td bgcolor=’efefef’>"&Rs(1)&"</td>"&_
"<td bgcolor=’efefef’>"&Rs(2)&"</td>"&_
"<td bgcolor=’efefef’>"&Rs(3)&"</td>"&_
"<td bgcolor=’efefef’>"&Rs(4)&"</td>"&_
"<td bgcolor=’efefef’>"&Rs(5)&"</td>"&_
"</tr>"
If n=1 Then CursorBegin=Rs(0)
If n=DefRecordNum Or Rs.Eof Then CursorEnd=Rs(0)
Rs.MoveNext
Wend
End Function
‘-------------连接数据库-------------
Set conn=Server.CreateObject("Adodb.Connection")
‘SQLstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.Mappath("mldata.mdb")
SQLstr="Driver={SQL Server};server=(local);uid=zhuangwang;pwd=liusijing21;database=MSSQLSERVER"
conn.Open SQLstr
‘---------统计总记录数/总页数---------
‘-PS:推荐使用count(ID),ID为自动编号且索引,否则速度有可能大打折扣
‘-PS:此统计是本程序中最耗资源的一部分,如果取消这段程序,速度会快上10倍左右
Dim TotalRecords,TotalPages
SQLstr="Select count(ID) As RecordSum From ABC"
Set Rs=conn.Execute(SQLstr,0,1)
TotalRecords=Rs("RecordSum")
TotalPages=Abs(Int(TotalRecords/DefRecordNum*(-1)))
Rs.Close
Set Rs=Nothing
‘--------根据hav选择相应的SQL字串-----
Select Case(hav)
Case "back"
CursorEnd=CursorBegin
SQLstr="Select Top "&DefRecordNum&" ID,Title,FileName,K,ImgSize,NameSon From ABC Where ID<"&CursorBegin&" And ID In (Select Top "&DefRecordNum&" ID From ABC Where ID<"&CursorBegin&" Order by ID DESC) Order by ID"
Case "next"
SQLstr="Select Top "&DefRecordNum&" ID,Title,FileName,K,ImgSize,NameSon From ABC Where ID>"&CursorEnd&" Order by ID"
End Select
Set Rs=conn.Execute(SQLstr,0,1)
%>
<html>
<head>
<title>"无限流"分页程序 作者:Arbiter</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">td,br,div,p,body {font-size:12px}</style>
</head>
<script language="javascript">
var CurPageNum=<%=CurPageNum%>; //取得当前页码
var TotalPages=<%=TotalPages%>; //取得页面总数
function turnpage(func){
var CursorBegin=<%=CursorBegin%>; //取得第一个显示的记录的ID值
var CursorEnd=<%=CursorEnd%>; //取得最后一个显示的记录的ID值
var BackUrl=‘mllist.asp?CurPageNum=‘+(CurPageNum-1)+‘&CursorBegin=‘+CursorBegin+‘&CursorEnd=‘+CursorEnd+‘&hav=back‘;
var NextUrl=‘mllist.asp?CurPageNum=‘+(CurPageNum+1)+‘&CursorBegin=‘+CursorBegin+‘&CursorEnd=‘+CursorEnd+‘&hav=next‘;
if(CurPageNum<=1 && func==‘back‘){
location.href=‘#‘;
}else if(CurPageNum>=TotalPages && func==‘next‘){
location.href=‘#‘;
}else if(func==‘back‘){
location.href=BackUrl;
}else if(func=‘next‘){
location.href=NextUrl;
}
}
function showPage(num){
var aStr,CurPages,num;
num = 5;
aStr = "";
if(CurPageNum<0){
CurPages = 1;
}else {
if(CurPageNum>TotalPages){
CurPages = TotalPages;
}
CurPages = CurPageNum;
}
alert("CurPages:"+ CurPages + "TotalPages:" + TotalPages);
for (i = 0;CurPages+i<=TotalPages&&i<=num;i++)
{
aStr+=" "+(CurPages+i);
}
document.write(aStr);
}
</script>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="#E2F5FE">
<tr align="center">
<td colspan="2"><%Response.Write CurPageNum&"/"&TotalPages&"页 总记录数:"&TotalRecords%></td>
<td><a href="mllist.asp">首页</a> <a href=javascript:turnpage(‘back‘);>上一页</a>
<a href=javascript:turnpage(‘next‘);>下一页</a> </td>
</tr>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="3" bgcolor="#CCCCCC">
<tr>
<td>ID</td>
<td>Title</td>
<td>FileName</td>
<td>大小</td>
<td>尺寸</td>
<td>类别</td>
</tr>
<%
TurnPageFS(DefRecordNum)
Rs.Close
Set Rs=Nothing
conn.Close
Set conn=Nothing
%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="#E2F5FE">
<tr align="center">
<td colspan="2">
----<script language="javascript">showPage(5);</script>----
<%Response.Write CurPageNum&"/"&TotalPages&"页 总记录数:"&TotalRecords%></td>
<td><a href="mllist.asp">首页</a> <a href=javascript:turnpage(‘back‘);>上一页</a>
<a href=javascript:turnpage(‘next‘);>下一页</a> </td>
</tr>
</table>
<%
EndTime=Timer
Response.Write "<br>程序执行时间:"&(EndTime-BeginTime)*1000&"毫秒"
Response.Write " 第一条记录的ID值(CursorBegin)="&CursorBegin&" "
Response.Write "最后一条记录的ID值(CursorEnd)="&CursorEnd&"<br><br>"
%>
</body>
</html>
标签:des style http color java 使用 os io
原文地址:http://www.cnblogs.com/dabing150/p/3889420.html