asp 分頁函數(shù),可以顯示 1,2,3,4,5... 前十頁,后十頁,下一頁,上一頁
asp 分頁函數(shù),可以顯示 1,2,3,4,5... 前十頁,后十頁,下一頁,上一頁
方法一:
<%
SoFia_DbName="jiaoyou" '修改此處為你的SQL Server 數(shù)據(jù)庫名稱
YourServer = "seven" '修改此處為你的Sql Server數(shù)據(jù)庫地址
YourUid = "sa" '修改此處為你的數(shù)據(jù)庫用戶名
YourPassword = "struts" '修改此處為你的數(shù)據(jù)庫密碼
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數(shù)據(jù)庫出錯,請檢查相關(guān)設(shè)置……</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 '設(shè)置每頁的個數(shù)
strFile = "?" '設(shè)置當(dāng)前頁面的名稱
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軟件管理系統(tǒng) 全部軟件</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>
上一條:
網(wǎng)站百度快照回檔問題的經(jīng)驗下一條:
做網(wǎng)站SEO如何打造企業(yè)品牌