俺菜鸟一个,大家帮我看看这个分页程序吧

188888 2003-09-15 10:24:20
我至尽试了很多分页程序了,可是没有一个成功的.........
大家帮我修改一下,成功了就给分!!!

<%
on error resume next
if request.QueryString("page")="" then
page=1
else
page=cint(request.QueryString("page"))
set link1=server.CreateObject("adodb.connection")
link1.open "driver={sql server};server=leon;uid=sa;pwd=;database=pubs"
rs.open "select * from roysched",link1,1,1
rs.pagesize=12
rs.absolutepage=page
if err.number<>0 then
response.Write("出现异常错误")
response.End()
end if
%>
<base target="_blank">
<table border="1">
<%
for i=0 to rs.pagesize-1
if rs.eof then
exit for
response.Write "<tr><td>"&i+(page*13-13)+1&":<a href='"&rs("title_id")&"'>&rs("lorange")&"</a></td></tr>"
rs.movenext
end if
next
%>
<tr><td align=right>
<base target='_top'>
<%
pageleon=split(request.ServerVariables("QUERY_STRING")
if ubound(pagelen)<1 then
if page>1 then response.Write("<a href="fengye.asp?page=1">首页</a><a href="fengye.asp?page="&page-1&"">上页</a>")
else
response.Write("下页 尾页")
for i=1 to rs.pagecount
if i=page then
response.Write(i&"")
else
response.Write("<a href="fengye.asp?page="&i&"">"&i&"</a>")
next
end if
rs.close
set rs=nothing
set link1=nothing
%>
</table>
...全文
31 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
188888 2003-09-15
  • 打赏
  • 举报
回复
我用了yzwxjun(蝼蚁飞舞)出现

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft VBScript 编译器错误 错误 '800a0401'

语句未结束

/yy.asp,行35

response.write "[<a href=yy.asp?page="&(pg-1)">上一页</a>] "
------------------------------------------^
tigerwen01 2003-09-15
  • 打赏
  • 举报
回复
copy就用:
aaa.asp:
<%Response.Buffer=True%>
<%
Dim n,PgSz,Total,PageNo,position,pagebegin,pagend,TotalRs
n=1
PgSz=5
Dim bConn,bRs,bsql
'''''开始连接数据库'''''''
Set bConn=Server.CreateObject("ADODB.Connection")
Connstr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+server.mappath("Data.mdb")
bConn.Open connstr
'''''连接数据库结束'''''''
Set bRs=Server.CreateObject("ADODB.RecordSet")
bsql="select * from yourTb"
bRs.open bsql,bConn,1,1
%>
<table width="100%">
<tr>
<td width="20%" bgcolor="#0B9EDD"><font color="#FFFFFF"><b>姓名</b></font></td><td width="40%" bgcolor="#0B9EDD"><font color="#FFFFFF"><b>性别</b></font></td><td width="20%" bgcolor="#0B9EDD"><font color="#FFFFFF"><b>住址</b></font></td><td width="20%" bgcolor="#0B9EDD"><font color="#FFFFFF"><b>电话</b></font></td>
</tr>
</table>
<%
TotalRs=bRs.RecordCount
if bRs.RecordCount =0 then
Response.Write "<font color=#FF0000>暂时还没有数据。</font>"
else
bRs.PageSize=Cint(PgSz)
Total=int(bRs.recordcount/PgSz*-1)*-1
PageNo=Request("pageno")
if PageNo="" then
PageNo=1
else
PageNo=PageNo+1
PageNo=PageNo-1
end if
ScrollAction=Request("ScrollAction")
if ScrollAction="首页" then
PageNo=1
end if
if ScrollAction="上一页" then
PageNo=PageNo-1
end if
if ScrollAction="下一页" then
PageNo=PageNo+1
end if
if ScrollAction="尾页" then
PageNo=Total
end if
if PageNo < 1 then
PageNo=1
end if
bRs.AbsolutePage=PageNo
position=bRs.PageSize*PageNo
pagebegin=position-bRs.PageSize+1
if position < bRs.RecordCount then
pagend=position
else
pagend=bRs.RecordCount
end if
Do while not (bRs is nothing)
RowCount=bRs.PageSize
Do while not bRs.eof and RowCount > 0

%>
<table width="100%">
<%
if n=1 then
Response.Write "<tr bgcolor=#EEEEEE>"
else
Response.Write "<tr bgcolor=#FFFFFF>"
end if
%>

<td width="20%"><%=bRs("userName")%></td><td width="40%"><%=bRs("sex")%></td><td width="20%"><%=bRs("Add")%></td><td width="20%"><%=bRs("phone")%></td>
</tr>
</table>
<%
n=1-n
RowCount=RowCount-1
bRs.MoveNext
Loop

'''''释放资源'''''''''''
bRs.close
bConn.close
set bRs=nothing
set bConn=nothing
%>
</td>
</tr>
<form method=post action="aaa.asp">
<input type="hidden" name="pageno" value="<%=PageNo%>">
<tr>
<td width="50%" height="1" bgcolor="#FF9900">[共有<B><%=TotalRs%></B>条信息,显示<B><%=pagebegin%>-<%=pagend%></B>条信息。]</td>
<td width="50%" height="1" bgcolor="#FF9900">
<p align="right">
<%
if PageNo > 1 then
response.write "<input type=submit name='ScrollAction' value='首页' class='but'> "
response.write "<input type=submit name='ScrollAction' value='上一页' class='but'> "
end if
if RowCount=0 and PageNo <> Total then
response.write "<input type=submit name='ScrollAction' value='下一页' class='but'> "
response.write "<input type=submit name='ScrollAction' value='尾页' class='but'> "
end if
%>

</td>
</tr>
</form>
<%
loop
end if
%>

</table>
</td>
</tr>
</table>
yzwxjun 2003-09-15
  • 打赏
  • 举报
回复
pg=clng(request("page"))'设置一个存放页的变量
'此处链接你的数据库
if not rs.eof then
rs.pagesize=2'设置每页多少个记录
if request("page")="" then
pg=1
rs.absolutepage=1
else
rs.absolutepage=request("page")
end if
end if
'此处放你的其他程序
<%for i=1 to rs.pagesize
if rs.eof then
exit for
end if
%>
'此处放你的记录
<%rs.movenext
next
%>
----下面是分页
<form action=你的页面.asp method=post>'此表单为你在文本框输入页数,直接跳转
<td height="19" colspan="8" class="f"> 
<% if pg<1 then pg=1
if pg>rs.pagecount then pg=rs.pagecount

if pg<>1 then
response.write "[<a href=你的页面.asp?page=1>第一页</a>] "
response.write "[<a href=你的页面.asp?page="&(pg-1)">上一页</a>] "
end if

if pg<>rs.pagecount then
response.write "[<a href=你的页面.asp?page="&(pg+1)">下一页</a>] "
response.write "[<a href=你的页面.asp?page="&rs.pagecount&">最后一页</a>] "
end if
%>
输入页数:
<input size=3 name="page">
[记录共<font color=CE3100><%=rs.recordcount%></font>条/<font color=CE3100><%=rs.PageCount%></font>页/当前第<font color=CE3100><%=pg%></font>页]
     
</form>
Primer2002cn 2003-09-15
  • 打赏
  • 举报
回复
rs.open "select * from roysched",link1,3,1
富察咪咪 2003-09-15
  • 打赏
  • 举报
回复
没有你的数据库,没法绑你改,贴出你的MAIL给你个现成的例子如何?
cshadow 2003-09-15
  • 打赏
  • 举报
回复
<%
on error resume next
if request.QueryString("page")="" then
page=1
else
page=cint(request.QueryString("page"))
end if
set link1=server.CreateObject("adodb.connection")
link1.open "driver={sql server};server=leon;uid=sa;pwd=;database=pubs"
rs.open "select * from roysched",link1,3,1
rs.pagesize=12
rs.absolutepage=page
if err.number<>0 then
response.Write("出现异常错误")
response.End()
%>
gshope 2003-09-15
  • 打赏
  • 举报
回复
rs.open "select * from roysched",link1,3,1
arhui007 2003-09-15
  • 打赏
  • 举报
回复
上面是我做的一个程序

呵呵~仅供参考
arhui007 2003-09-15
  • 打赏
  • 举报
回复
<!--#include file="inc/conn.asp" -->
<!--#include file="inc/code.inc" -->
<%
userid=DecodeCookie(request.cookies("userid"))
password=DecodeCookie(request.cookies("password"))
level=DecodeCookie(request.cookies("level"))
%>

<%
Set RS = Server.CreateObject("ADODB.RecordSet")
sql = "SELECT * FROM ldjh order by ID desc"
RS.open sql,Conn,1,1
%>
<%
rs.PageSize =10
Sub ShowOnePage( rs, Page )

rs.AbsolutePage = Page '设置当前页号
%>
<TABLE BORDER=0 width=100% cellspacing=1 cellpadding=3 align=left class="table2">
<tr bgcolor="#F5F5F5">
<td width="20%" class="td2" align="center" bgcolor="#E1E1E1"><B>标 题</b></td>
<td width="20%" align="center" class="td2" bgcolor="#E1E1E1"><B>讲 话 人</b></td>
<td width="20%" align="center" class="td2" bgcolor="#E1E1E1"><B>日 期</b></td>
</tr>
<%
For iPage = 1 To rs.PageSize '输出当前页的所有记录
RecNo = (Page - 1) * rs.PageSize + iPage '计算输出的记录序号
%>
<tr bgcolor="#F5F5F5">
<%if len(trim(RS("title")))>20 then%>
<td width="50%" height="12" class="td2"> <a href="javascript:newwin('ldjh.asp?ID=<%=RS("ID")%>')" title="<img src=images/zhuti.gif><%=RS("title")%><br><img src=images/zuozhe.gif>讲话人:<%=RS("fyr")%><br><img src=images/lasttime.gif>日 期:<%=FormatDateTime(RS("date"),1)%> <br>"><%=mid((trim(RS("title"))),1,20)%>...</a> </td>
<%else%>
<td width="50%" height="12" class="td2"> <a href="javascript:newwin('ldjh.asp?ID=<%=RS("ID")%>')" title="<img src=images/zhuti.gif><%=RS("title")%><br><img src=images/zuozhe.gif>讲话人:<%=RS("fyr")%><br><img src=images/lasttime.gif>日 期:<%=FormatDateTime(RS("date"),1)%> <br>"><%=RS("title")%></a> </td>
<%end if%>
<td width="300" height="12" class="td2"> <%=RS("fyr")%> </td>
<td width="400" height="12" align="left" class="td2"> <%=FormatDateTime(RS("date"),1)%>  </td>
</tr>
<%
rs.MoveNext
If rs.EOF Then Exit For
Next
Response.Write "</TABLE>"
End Sub
%>
<%
If Request("Page") = "" Then Page=10
Page = CLng(Request("Page")) ' CLng 不可省略,用于将页码转换为长整型
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
position=RS.PageSize*Page
pagebegin=position-RS.PageSize+1
if position <RS.RecordCount then
pagend=position
else
pagend= RS.RecordCount
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title>领导讲话</title>
<style type="text/css">
<!--
A:link {text-decoration: none; color:#000000}
A:visited {text-decoration: none; color: #000000}
A:hover{text-decoration: underline; color : #FF0000;}
td {font-size: 11pt; color: #000000}
.table2{}
.td2{}

body{FONT-FAMILY: 宋体; FONT-SIZE: 9pt;}
-->
</style>

<script language="javaScript" type="text/javascript" SRC="images/title.js"></SCRIPT>
<script language="javascript">
<!--
function newwin(url){
window.open(url,"win");
}
//-->
</script>
</head>
<body bgcolor="#ffffff" text=#cc0000 background="" topmargin="0" leftmargin="0">
<table width="100%" border="0">
<tr>
<td>
<%
ShowOnePage rs, Page
%>
</td>
</tr>
</table>
<form action="list.asp" method="GET">
<table border="0" width="100%" height="1" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="13">
<%
If Page <> 1 Then
Response.Write "<A HREF=list.asp?Page=1><img src=images/first.gif title=第一页 border=0></A>"
Response.Write "<A HREF=list.asp?Page=" & (Page-1) & "><img src=images/prev.gif border=0 title=上一页></A>"
End If
If Page <> rs.PageCount Then
Response.Write "<A HREF=list.asp?Page=" & (Page+1) & "><img src=images/next.gif border=0 title=下一页></A>"
Response.Write "<A HREF=list.asp?Page=" & rs.PageCount & "><img src=images/last.gif title=最后一页 border=0></A>"
End If
%>
</td></tr>
<tr>
<td width="100%" height="1"><font color=008800>
页数:<font color="#FF0000"><%=Page%>/<%=rs.PageCount%></font>
共有<font color="#FF0000"> <%=RS.RecordCount%></font> 条信息,每页显示<font color=ff0000><%=rs.PageSize%></font>条 当前显示<font color=ff0000><%=pagebegin%>-<%=pagend%></font>条</font>[<a href=login.asp target=_blank><font color=cccccc>管理</font></a>]
</td>
</tr>
</table>
</form>
<table border="0" width="700" height="100" cellspacing="0" cellpadding="0" align=left>
<tr>
<td align=left>
<div align="left">
<left>
<table border="0" width="100%" height="31" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="25">
<form method="POST" action="search.asp" target=_blank>
请输入要查询的条件:<input type="text" name="title" size="35"> 
<input type="radio" value="LD" name="R1">按领导  <input type="radio" value="BT" checked name="R1">按标题 
<input type="submit" value="提交" name="B1">
</form>
</td>
</tr>
</table>
</left>
</div>
</td>
</tr>
</table>
</body>
</html>
188888 2003-09-15
  • 打赏
  • 举报
回复
好象可以了,呵呵,谢谢大家了,分吧.......
YesOrNo2003 2003-09-15
  • 打赏
  • 举报
回复
晕,再多看看别人的,只要知道了一个,就会全通。
yzwxjun 2003-09-15
  • 打赏
  • 举报
回复
对,小打了一个&
富察咪咪 2003-09-15
  • 打赏
  • 举报
回复
response.write "[<a href=yy.asp?page="&(pg-1) & ">上一页</a>] "

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧