做过两个展示商品的网站,于是用到下面的代码:
<%
set rs=server.createobject("adodb.recordset")
sqls="select * from products order by id asc"
rs.open sqls,conn,1,1
IF not rs.eof Then
proCount=rs.recordcount
rs.PageSize=12 '定义显示数目
if not IsEmpty(Request("ToPage")) then
ToPage=CInt(Request("ToPage"))
if ToPage>rs.PageCount then
rs.AbsolutePage=rs.PageCount
intCurPage=rs.PageCount
elseif ToPage<=0 then
rs.AbsolutePage=1
intCurPage=1
else
rs.AbsolutePage=ToPage
intCurPage=ToPage
end if
else
rs.AbsolutePage=1
intCurPage=1
end if
intCurPage=CInt(intCurPage)
k=1
do while Not rs.eof and k<4 '控制显示行数
%>
<%
for n=1 to 4
%>
| <% if len(rs("title"))<=8 then Response.write rs("title") else response.write left(rs("title"),8)&"..." end if %>
|
|
|
|
<%
rs.movenext
if rs.eof then exit for
if rs.eof then exit do
Next
%>
<%
k=k+1
Loop
%>
总共:<%=rs.PageCount%>页, <%=proCount%>个产品, 当前页: <%=intCurPage%> <% if intCurPage<>1 then %> 首页|上一页| <% end if if intCurPage<>rs.PageCount then %> 下一页| 最后一页 <% end if%> <%end if%>
|
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21022866/viewspace-566841/
,如需转载,请注明出处,否则将追究法律责任。