新微赢技术网

标题: 翻页? [打印本页]

作者: 导演    时间: 2010-1-19 03:46
标题: 翻页?
这是一个带列表的翻页程序:
<!--#include file="conn.inc"-->
<link href="../text.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #C4ECFF;
}
.style1 {font-size: 12px}
-->
</style><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<p>&nbsp;</p>
<p align="center"><strong>图片管理</strong></p>
<table width="599" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#C4ECFF">
<%
set rs=server.createobject("adodb.recordset")
sql= "SELECT * FROM img order by id Desc "
rs.open sql,conn,1,1
if rs.eof and rs.bof then %>
<p align="center">&nbsp;</p>
<p align="center"><span class="style1">还没有图片!</span><br>
</p>
<%
else
dim MaxPerPage
dim sql
dim rs
dim gstBookID
dim totalPut
dim CurrentPage
dim TotalPages
filename="Manage_Img.asp"
if not isempty(request("page")) then
currentPage=request("page")
else
currentPage=1
end if
rs.pagesize=10
totalPut=rs.recordcount '记录总数
totalPage=rs.pagecount
MaxPerPage=rs.pagesize
if currentpage<1 then
currentpage=1
end if
if currentpage>totalPage then
currentpage=totalPage
end if
if currentPage=1 then
showContent
showpages1
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark '移动到开始显示的记录位置
showContent
showpages1
end if
end if
rs.close
end if
set rs=nothing

set conn=nothing
sub showContent
dim i,j
%>
<table width="115" height="26" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><table width="570" border="0" align="center" cellpadding="0" cellspacing="0" class="default">
<tr align="center" onmouseover="javascript:this.bgColor='#F7F7F7';" onmouseout="javascript:this.bgColor='#C4ECFF';"">
<td width="58" height="28" class="style1">序号</td>
<td width="98" class="style1">图片名称</td>
<td width="93" class="style1">图片</td>
<td width="125" align="right"><div align="center" class="style1">添加日期</div></td>
<td width="147" class="style1">操作</td>
<td width="49" class="style1">操作</td>
</tr>
<%
i=1
do while not (rs.eof or err)%>
<tr onmouseover="javascript:this.bgColor='#F7F7F7';" onmouseout="javascript:this.bgColor='#C4ECFF';"">
<td height="25" align="center" class="style1"><%=rs("id")%></td>
<td style="padding-left:10px"><div align="center"><a href="imagesnew.asp?id=<%=rs("id")%>" target="_blank" class="style1"><%=rs("title")%></a></div></td>
<td align="center"><img name="" src="http://www.qyph.com.cn/<%=rs("img")%>" width="90" height="60" alt=""></td>
<td align="center" class="style1"><%=rs("time")%></td>
<td align="center"><a href="Manage_editImg.asp?id=<%=rs("id")%>" class="style1">修改</a></td>
<td align="center"><a href="del_Img.asp?id=<%=rs("id")%>" class="style1">删除</a></td>
</tr>
<%
if i>=MaxPerPage then exit do
i=i+1
rs.movenext
loop
%>
<tr>
<td height="30" colspan="7" align="center">
<%
end sub
%>
<%
sub showpages1()
dim n
n=totalPage
%>
<form action="<%=filename%>" method="post" align="right">
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td height="30">
<div align="right"> <span style="font-size:9pt"> <span class="style1">共<font color="#FF0000"><%=totalPage%></font>页/<font color="red"><%=totalPut%></font>条信息 </span></span>
<span class="style1">
<% If currentPage <> 1 Then %>
<a href=<%=filename%>><font color="#FF6600"><span style="font-size:9pt">[首页]</span></font></a> <a href=<%=filename%>?Page=<%=(currentPage-1)%>><font color="#FF6600"><span style="font-size:9pt">[上一页]</span></font></a>
<% End If %>
<% If currentPage <> rs.PageCount Then %>
<a href=<%=filename%>?Page=<%=(currentPage+1)%>><font color="#FF6600"><span style="font-size:9pt">[下一页]</span></font></a> <a href=<%=filename%>?Page=<%=totalPage%>><font color="#FF6600"><span style="font-size:9pt">[尾页]</span></font></a>
<% End If %>
<span style="font-size:9pt"> 第<font color="#FF0000"><%=currentPage%></font>页/共<font color="#FF0000"><%=totalPage%></font>页
<%
response.write " 转到:<select name='page' size=1 class=smallselsect style='font-family: 宋体; font-size: 9pt;'>"
for i=1 to n
response.write "<option value="& i
if currentpage=i then
response.write " selected"
end if
response.write ">"& i &"</option>"
next
response.write "</select>"
response.write"<input name='types' type='hidden' value='"&request("types")&"'>"
response.write "&nbsp;<input class=buttonface type='submit' value='go' style='font-family: 宋体; font-size: 9pt;'>"
%>
</span></span> </div></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table>
<%end sub%>
</p></td>
</tr>
</table>
</td>
</tr>
</table>
没有提示错误,但是一点“下一页”就直接蹦到“尾页”,中间的几页出不来,为什么?
作者: ████    时间: 2010-1-19 03:46
代码没错..汗..你看看是不是你的数据有问题因为我用的就是这个分页.
作者: 飘渺    时间: 2010-1-19 03:46
数据库会有什么问题
作者: 渴望光明    时间: 2010-1-19 03:47
没有人知道嘛
作者: 爱(じΩvê)    时间: 2010-1-19 03:47
怎么给你测试 要不你把能运行的包括数据库的一套程序发上来




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2