
求高手帮修改一段asp代码 分页有问题
分页不正常我想搞成上一页下一页样式求高手修改下帖到回复中谢谢!<%sql="selectid,x_jingdiantupian,x_name,x_baojia,x_shi...
分页不正常 我想搞成 上一页 下一页样式 求高手修改下
帖到回复中谢谢!
<%
sql="select id,x_jingdiantupian,x_name,x_baojia,x_shijian,x_leixun from xianlu"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,2
y=5
rs.pagesize=y
pageno=request.QueryString("pageno")
if pageno="" then
pageno=1
else
pageno=cint(pageno)
end if
rs.absolutepage=pageno
do while not rs.eof
%>
<tr><td width="34%" rowspan="4"><TABLE width=130 height="89" border=0 cellPadding=0 cellSpacing=0><TBODY>
<TR>
<TD width="122"><div align="center"><img src="admin/<%=rs("x_jingdiantupian")%>" width="122" height="86" border="0"></div></TD>
<TD width="10"><IMG src="images/mfk_97.gif" width="8" height="88"></TD>
</TR></TBODY></TABLE></td><td width="16%" height="18">产品名称:</td><td colspan="3"><font color="#006699">
<%if len(rs("x_name"))>10 then%>
<%=left(rs("x_name"),10)%>
<%else%>
<%=rs("x_name")%>
<%end if%>
</font></td></tr><tr><td height="18">特惠价格:</td><td width="15%"><%=rs("x_baojia")%></td>
<td width="16%"> 产品规格: </td>
<td width="19%"><%=rs("x_shijian")%></td></tr><tr>
<td height="18"> 产品类型:</td><td height="18"><%=rs("x_leixun")%></td>
<td height="18"> </td><td height="18"> </td>
</tr><tr>
<td height="27" colspan="4"><table width="97%" height="22" border="0" cellpadding="0" cellspacing="0"><tr>
<td><div align="left"><a href="Products/Product_<%=rs("id")%>.html"><img src="images/9.png" width="67" height="21" border="0"></a></div></td>
<td><div align="right"><a href="giveme.asp?id=<%=rs("id")%>"><img src="images/10.png" width="67" height="21" border="0"></a></div></td>
</tr></table></td></tr><tr bgcolor="#CCCCCC"><td height="1" colspan="5"></td></tr>
<%
Rs.movenext
y=y-1
Loop
%>
</table></td>
<td width="16" valign="top"><img src="images/right.gif" width="16" height="175"></td>
</tr>
<tr>
<td height="25" valign="top"> </td>
<td height="30" align="center" valign="middle">
<%
if pageno=0 or 1 and pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> 上一页 <a href=products.asp?pageno=2>下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
else
if pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&rs.pagecount-1&">上一页</a> 下一页 最后页")
end if
if pageno>1 and pageno<rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&pageno-1&">上一页</a> <a href=products.asp?pageno="&pageno+1&">下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
end if
end if
%>
<%
response.Write(pageno&"/"&rs.pagecount)
%></td>
<td height="25" valign="top"> </td>
</tr>
</table></TD>
</TR></TBODY></TABLE></TD>
</TR></TBODY></TABLE>
</BODY></HTML> 展开
帖到回复中谢谢!
<%
sql="select id,x_jingdiantupian,x_name,x_baojia,x_shijian,x_leixun from xianlu"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,2
y=5
rs.pagesize=y
pageno=request.QueryString("pageno")
if pageno="" then
pageno=1
else
pageno=cint(pageno)
end if
rs.absolutepage=pageno
do while not rs.eof
%>
<tr><td width="34%" rowspan="4"><TABLE width=130 height="89" border=0 cellPadding=0 cellSpacing=0><TBODY>
<TR>
<TD width="122"><div align="center"><img src="admin/<%=rs("x_jingdiantupian")%>" width="122" height="86" border="0"></div></TD>
<TD width="10"><IMG src="images/mfk_97.gif" width="8" height="88"></TD>
</TR></TBODY></TABLE></td><td width="16%" height="18">产品名称:</td><td colspan="3"><font color="#006699">
<%if len(rs("x_name"))>10 then%>
<%=left(rs("x_name"),10)%>
<%else%>
<%=rs("x_name")%>
<%end if%>
</font></td></tr><tr><td height="18">特惠价格:</td><td width="15%"><%=rs("x_baojia")%></td>
<td width="16%"> 产品规格: </td>
<td width="19%"><%=rs("x_shijian")%></td></tr><tr>
<td height="18"> 产品类型:</td><td height="18"><%=rs("x_leixun")%></td>
<td height="18"> </td><td height="18"> </td>
</tr><tr>
<td height="27" colspan="4"><table width="97%" height="22" border="0" cellpadding="0" cellspacing="0"><tr>
<td><div align="left"><a href="Products/Product_<%=rs("id")%>.html"><img src="images/9.png" width="67" height="21" border="0"></a></div></td>
<td><div align="right"><a href="giveme.asp?id=<%=rs("id")%>"><img src="images/10.png" width="67" height="21" border="0"></a></div></td>
</tr></table></td></tr><tr bgcolor="#CCCCCC"><td height="1" colspan="5"></td></tr>
<%
Rs.movenext
y=y-1
Loop
%>
</table></td>
<td width="16" valign="top"><img src="images/right.gif" width="16" height="175"></td>
</tr>
<tr>
<td height="25" valign="top"> </td>
<td height="30" align="center" valign="middle">
<%
if pageno=0 or 1 and pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> 上一页 <a href=products.asp?pageno=2>下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
else
if pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&rs.pagecount-1&">上一页</a> 下一页 最后页")
end if
if pageno>1 and pageno<rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&pageno-1&">上一页</a> <a href=products.asp?pageno="&pageno+1&">下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
end if
end if
%>
<%
response.Write(pageno&"/"&rs.pagecount)
%></td>
<td height="25" valign="top"> </td>
</tr>
</table></TD>
</TR></TBODY></TABLE></TD>
</TR></TBODY></TABLE>
</BODY></HTML> 展开
3个回答
展开全部
全部关键代码。
<%
dim page //当前页
dim showcount //每页显示多少条
dim pagecount //总页数
page = request.querystring("page") //得到页号
if page = "" then page = 1 //没有页号就是第一页
if not isNumeric(page) then page = 1 //页号不正常也是第一页
showcount = 20 //每页显示20条
... asp ...
rs.open sql, conn, 3, 2
rs.pagesize = showcount //设定RS页宽
pagecount = rs.pagecount //得到总页数
if int(page) <= int(pagecount) then rs.absolutepage = int(page)
//如果当前页比总页小则设定当前页显示
%>
...HTML...
<a href="?page=<% =page - 1 %>">上一页</a>
<a href="?page=<% =page + 1 %>">下一页</a>
<%
dim page //当前页
dim showcount //每页显示多少条
dim pagecount //总页数
page = request.querystring("page") //得到页号
if page = "" then page = 1 //没有页号就是第一页
if not isNumeric(page) then page = 1 //页号不正常也是第一页
showcount = 20 //每页显示20条
... asp ...
rs.open sql, conn, 3, 2
rs.pagesize = showcount //设定RS页宽
pagecount = rs.pagecount //得到总页数
if int(page) <= int(pagecount) then rs.absolutepage = int(page)
//如果当前页比总页小则设定当前页显示
%>
...HTML...
<a href="?page=<% =page - 1 %>">上一页</a>
<a href="?page=<% =page + 1 %>">下一页</a>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%
sql="select * from new order by id desc"
set C=server.createobject("adodb.recordset")
C.open sql,conn,1,1
mypage=request("whichpage")
if mypage="" then
mypage=1
else
mypage=cint(mypage)
end if
mypagesize=request("pagesize")
if mypagesize="" then
mypagesize=15
end if
C.movefirst
C.pagesize=mypagesize
maxcount=cint(C.pagecount)
C.absolutepage=mypage
how=1
y=C.pagecount
d=C.recordcount
%>
<%do while not C.eof and how <=C.pagesize%>
<%
C.movenext
how=how+1
loop
%>
<%
if mypage<>1 then
response.write"<a href=more.asp> [第一页] </a>"
response.write"<a href=more.asp?whichpage="&(mypage-1)&"> [上一页] </a>"
end if
if mypage<>y then
response.write"<a href=more.asp?whichpage="&(mypage+1)&"> [下一页] </a>"
response.write"<a href=more.asp?whichpage="&y&"> [最后一页] </a>"
end if
%>
</span> 当前为<%=mypage%>页 共有<%=maxcount%>页 共有<%=d%>条新闻
sql="select * from new order by id desc"
set C=server.createobject("adodb.recordset")
C.open sql,conn,1,1
mypage=request("whichpage")
if mypage="" then
mypage=1
else
mypage=cint(mypage)
end if
mypagesize=request("pagesize")
if mypagesize="" then
mypagesize=15
end if
C.movefirst
C.pagesize=mypagesize
maxcount=cint(C.pagecount)
C.absolutepage=mypage
how=1
y=C.pagecount
d=C.recordcount
%>
<%do while not C.eof and how <=C.pagesize%>
<%
C.movenext
how=how+1
loop
%>
<%
if mypage<>1 then
response.write"<a href=more.asp> [第一页] </a>"
response.write"<a href=more.asp?whichpage="&(mypage-1)&"> [上一页] </a>"
end if
if mypage<>y then
response.write"<a href=more.asp?whichpage="&(mypage+1)&"> [下一页] </a>"
response.write"<a href=more.asp?whichpage="&y&"> [最后一页] </a>"
end if
%>
</span> 当前为<%=mypage%>页 共有<%=maxcount%>页 共有<%=d%>条新闻
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
帮你改了,主要错误是循环时,没有限制分页
<%
sql="select id,x_jingdiantupian,x_name,x_baojia,x_shijian,x_leixun from xianlu"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,2
pagesize=5
rs.pagesize=pagesize
pageno=request.QueryString("pageno")
if pageno="" then
pageno=1
else
pageno=cint(pageno)
end if
rs.absolutepage=pageno
i=0
do while not rs.eof and i<rs.pagesize'主要在这里
%>
<tr><td width="34%" rowspan="4"><TABLE width=130 height="89" border=0 cellPadding=0 cellSpacing=0><TBODY>
<TR>
<TD width="122"><div align="center"><img src="admin/<%=rs("x_jingdiantupian")%>" width="122" height="86" border="0"></div></TD>
<TD width="10"><IMG src="images/mfk_97.gif" width="8" height="88"></TD>
</TR></TBODY></TABLE></td><td width="16%" height="18">产品名称:</td><td colspan="3"><font color="#006699">
<%if len(rs("x_name"))>10 then%>
<%=left(rs("x_name"),10)%>
<%else%>
<%=rs("x_name")%>
<%end if%>
</font></td></tr><tr><td height="18">特惠价格:</td><td width="15%"><%=rs("x_baojia")%></td>
<td width="16%"> 产品规格: </td>
<td width="19%"><%=rs("x_shijian")%></td></tr><tr>
<td height="18"> 产品类型:</td><td height="18"><%=rs("x_leixun")%></td>
<td height="18"> </td><td height="18"> </td>
</tr><tr>
<td height="27" colspan="4"><table width="97%" height="22" border="0" cellpadding="0" cellspacing="0"><tr>
<td><div align="left"><a href="Products/Product_<%=rs("id")%>.html"><img src="images/9.png" width="67" height="21" border="0"></a></div></td>
<td><div align="right"><a href="giveme.asp?id=<%=rs("id")%>"><img src="images/10.png" width="67" height="21" border="0"></a></div></td>
</tr></table></td></tr><tr bgcolor="#CCCCCC"><td height="1" colspan="5"></td></tr>
<%
Rs.movenext
i=i+1'i在记录循环时自动加1
Loop
%>
</table></td>
<td width="16" valign="top"><img src="images/right.gif" width="16" height="175"></td>
</tr>
<tr>
<td height="25" valign="top"> </td>
<td height="30" align="center" valign="middle">
<%
if pageno=0 or 1 and pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> 上一页 <a href=products.asp?pageno=2>下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
else
if pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&rs.pagecount-1&">上一页</a> 下一页 最后页")
end if
if pageno>1 and pageno<rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&pageno-1&">上一页</a> <a href=products.asp?pageno="&pageno+1&">下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
end if
end if
%>
<%
response.Write(pageno&"/"&rs.pagecount)
%></td>
<td height="25" valign="top"> </td>
</tr>
</table></TD>
</TR></TBODY></TABLE></TD>
</TR></TBODY></TABLE>
</BODY></HTML>
<%
sql="select id,x_jingdiantupian,x_name,x_baojia,x_shijian,x_leixun from xianlu"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,2
pagesize=5
rs.pagesize=pagesize
pageno=request.QueryString("pageno")
if pageno="" then
pageno=1
else
pageno=cint(pageno)
end if
rs.absolutepage=pageno
i=0
do while not rs.eof and i<rs.pagesize'主要在这里
%>
<tr><td width="34%" rowspan="4"><TABLE width=130 height="89" border=0 cellPadding=0 cellSpacing=0><TBODY>
<TR>
<TD width="122"><div align="center"><img src="admin/<%=rs("x_jingdiantupian")%>" width="122" height="86" border="0"></div></TD>
<TD width="10"><IMG src="images/mfk_97.gif" width="8" height="88"></TD>
</TR></TBODY></TABLE></td><td width="16%" height="18">产品名称:</td><td colspan="3"><font color="#006699">
<%if len(rs("x_name"))>10 then%>
<%=left(rs("x_name"),10)%>
<%else%>
<%=rs("x_name")%>
<%end if%>
</font></td></tr><tr><td height="18">特惠价格:</td><td width="15%"><%=rs("x_baojia")%></td>
<td width="16%"> 产品规格: </td>
<td width="19%"><%=rs("x_shijian")%></td></tr><tr>
<td height="18"> 产品类型:</td><td height="18"><%=rs("x_leixun")%></td>
<td height="18"> </td><td height="18"> </td>
</tr><tr>
<td height="27" colspan="4"><table width="97%" height="22" border="0" cellpadding="0" cellspacing="0"><tr>
<td><div align="left"><a href="Products/Product_<%=rs("id")%>.html"><img src="images/9.png" width="67" height="21" border="0"></a></div></td>
<td><div align="right"><a href="giveme.asp?id=<%=rs("id")%>"><img src="images/10.png" width="67" height="21" border="0"></a></div></td>
</tr></table></td></tr><tr bgcolor="#CCCCCC"><td height="1" colspan="5"></td></tr>
<%
Rs.movenext
i=i+1'i在记录循环时自动加1
Loop
%>
</table></td>
<td width="16" valign="top"><img src="images/right.gif" width="16" height="175"></td>
</tr>
<tr>
<td height="25" valign="top"> </td>
<td height="30" align="center" valign="middle">
<%
if pageno=0 or 1 and pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> 上一页 <a href=products.asp?pageno=2>下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
else
if pageno=rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&rs.pagecount-1&">上一页</a> 下一页 最后页")
end if
if pageno>1 and pageno<rs.pagecount then
response.Write("<a href=products.asp>首页</a> <a href=products.asp?pageno="&pageno-1&">上一页</a> <a href=products.asp?pageno="&pageno+1&">下一页</a> <a href=products.asp?pageno="&rs.pagecount&">最后页</a>")
end if
end if
%>
<%
response.Write(pageno&"/"&rs.pagecount)
%></td>
<td height="25" valign="top"> </td>
</tr>
</table></TD>
</TR></TBODY></TABLE></TD>
</TR></TBODY></TABLE>
</BODY></HTML>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询