请帮忙看看这个分页程序!

cwjdily 2003-10-17 02:52:31
请大家帮忙看看这个程序,可以分页,但是上一页,下一页却不起作用,而且总是读取同一条信息是怎么回事?




<!-- #INCLUDE FILE="conn.asp" -->

<%
response.buffer=true
Response.Expires=0
sql="select * from news where news_native='"&request("native")&"' order by news_date"
Set rs = Server.CreateObject("ADODB.Recordset")

rs.open sql,conn,1

page=1
rs.PageSize =20

if Not IsEmpty(Request("Page")) then

Page = CInt(Request("Page"))

if Page > rs.PageCount then
rs.AbsolutePage = rs.PageCount

elseif Page <= 0 then
Page = 1
else
rs.AbsolutePage = Page
end if
End if
intCurPage = rs.AbsolutePage
%>
<body bgColor="#ffffff" topMargin="0" link="#2F4F4F" vlink="#2F4F4F" alink="#2F4F4F" text="#808080" leftmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<center>
<table width=778 border=0 cellpadding=0 cellspacing=0>
<tr>
<td> <img src="images/top_01.jpg" width=78 height=84></td>
<td> <img src="images/top_02.jpg" width=78 height=84></td>
<td> <img src="images/top_03.jpg" width=77 height=84></td>
<td> <img src="images/top_04.jpg" width=78 height=84></td>
<td> <img src="images/top_05.jpg" width=78 height=84></td>
<td> <img src="images/top_06.jpg" width=78 height=84></td>
<td> <img src="images/top_07.jpg" width=78 height=84></td>
<td> <img src="images/top_08.jpg" width=77 height=84></td>
<td> <img src="images/top_09.jpg" width=78 height=84></td>
<td> <img src="images/top_10.jpg" width=78 height=84></td>
</tr>
</table>
<table width="778" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/bg.jpg" width="230" rowspan="2"> </td>
<td> </td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="p9-150"> <font color=#FF9933> <b> </b></font>
<div align="left"><font color="#000000"><span class=txt> </span><br>
<%if page<>1 then%>
<a Href="nesw2.asp?Page=<% = 1%>">首页</a>
<a Href="nesw2.asp?Page=<% =intCurPage -1 %>">上一页</a>
<%end if %>
<%if page<>rs.pagecount then %>
<a Href="nesw2.asp?Page=<% =intCurPage + 1%>">下一页</a>
<a Href="nesw2.asp?Page=<% = rs.PageCount%>">尾页</a>
<% end if %>
<hr>
<%
For i = 1 to rs.PageSize
if rs.eOF then
Exit For
end if
%>

<img src="images/pot.gif" width="17" height="13">  <font
class="p9-200"><%=rs("news_date")%></font>  <a
href="disp.asp?recno=<%=rs("news_no")%>" target="news"><%=rs("news_title")%></a>
<br>
<%
next
%>
<hr>
</tr>
</table>
</center>
</body>
<script language="JavaScript">
function news()
{

window.open("temp.htm","news","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=2,left=2,width=500,height=500")
//window.open("1.htm","news","width=470,height=500");

}
</script>
...全文
57 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolboy0000love 2003-10-24
  • 打赏
  • 举报
回复
这里错误了
<%if page<>1 then%>
<a Href="nesw2.asp?Page=<% = 1%>">首页</a>
<a Href="nesw2.asp?Page=<% =intCurPage -1 %>">上一页</a>
<%end if %>
<%if page<>rs.pagecount then %>
<a Href="nesw2.asp?Page=<% =intCurPage + 1%>">下一页</a>
<a Href="nesw2.asp?Page=<% = rs.PageCount%>">尾页</a>
<% end if %>
<hr>
该成
<%if page<>1 then%>
<a Href="nesw2.asp?Page=1">首页</a>
<a Href="nesw2.asp?Page=<% =page-1 %>">上一页</a>
<%end if %>
<%if page<>rs.pagecount then %>
<a Href="nesw2.asp?Page=<% =page+1%>">下一页</a>
<a Href="nesw2.asp?Page=<% = rs.PageCount%>">尾页</a>
<% end if %>
<hr>
xxsuperboy 2003-10-24
  • 打赏
  • 举报
回复
显示数字在中间部分会重复2次,你自己改下条件判断就行了


open ~~~~1,1(注意游标::)
xxsuperboy 2003-10-24
  • 打赏
  • 举报
回复
不好意思,这页页面还真的有问题:)我今天昨天晚上发现用了几次后,就不行了,问题跟你说的一样:)


今天在早上改了一下:)可以了,又加了几句代码:)

dim page
dim maxpageNO
dim pagecode(100,0)
page=1
maxpageNO = 2
rs.PageSize = maxpageNO


if Not IsEmpty(Request("Page")) then

Page = CInt(Request("Page"))

if Page > rs.PageCount then
rs.AbsolutePage = rs.PageCount


elseif page <= 0 then
page = 1
intCurPage = page
end if
End if
rs.AbsolutePage= page
%>
<% if page <>1 then %>
<a Href="fireinfolist.asp?Page=<% = 1%>">首页</a>
<%
for k = 1 to (rs.recordcount/maxpageNO)
pagecode(i,0) = k
%>
<a Href="fireinfolist.asp?Page=<% =pagecode(i,0) %>"><%=pagecode(i,0)%></a>
<%next%>
<a Href="fireinfolist.asp?Page=<% =Page -1 %>">上一页</a>
<%end if
if page<>rs.pagecount then %>
<a Href="fireinfolist.asp?Page=<% =page + 1%>">下一页</a>
<%
for k = 1 to (rs.recordcount/maxpageNO)
pagecode(i,0) = k
%>
<a Href="fireinfolist.asp?Page=<% =pagecode(i,0) %>"><%=pagecode(i,0)%></a>
<%next%>
<a Href="fireinfolist.asp?Page=<% = rs.PageCount %>">尾页</a>
<% end if %>
<%
For i = 1 to rs.PageSize
if rs.eOF then
Exit For
end if
%>

<tr bgcolor="">
<td width="12%" height="10" align="center" class="inboxpro"><%=rs("houseinfo")%></font></td>
<td width="10%" height="10" align="center" class="inboxpro"><%=rs("cityzone")%></font></td>
<td width="16%" height="10" align="center" class="inboxpro"><%=rs("xjcs")%></font></td>
<td width="20%" height="10" align="center" class="inboxpro"><%=rs("adressinfo")%></font></td>
<td width="12%" height="10" align="center" class="inboxpro"><%=rs("rateinfo")%></font></td>
<td width="17%" height="10" align="center" class="inboxpro"><%=rs("showdata")%></font></td>
<td width="12%" height="10" align="center" class="inboxpro"><a href="detailed.asp?idpro=<%=rs("id")%>" title="查看详细信息">详情</a></td>
</tr>
<%

rs.MoveNext

next
%>


希望能解决你的问题:)
lovehwq21 2003-10-23
  • 打赏
  • 举报
回复
哈哈……
楼主,我看了分页部分也没问题啊!!!
再换其它机子试试
xxsuperboy 2003-10-23
  • 打赏
  • 举报
回复
谢谢,我用了你的代码,实现了动态分页。


附:你的代码没有问题:)

28,390

社区成员

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

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