可以套用,测试通过
<!-- #include file="conn.asp" -->
<%
const MaxPerPage=10
records=200
pages=records/maxperpage
if pages<1 then pages=1 end if
currentpage=cint(request("currentpage"))
if currentpage="" or currentpage<1 then
currentpage=1
if currentpage>pages then currentpage=pages
end if
set rs=server.createobject("adodb.recordset")
sql="select * from view_products order by products_id desc limit "&(currentpage-1)*MaxPerPage&","&MaxPerPage
Rs.CursorLocation = 3
rs.open sql,conn
%>
<p>
<%
j=1
do while (not rs.eof) and j<=MaxPerPage
%>
<a href="productlist.asp?products_id=<%=rs("products_id")%>"><%=((currentpage-1)*10+j)%>.<%=rs("products_name")%></a><br/>
<%
rs.movenext
j=j+1
loop
%>
第<%=currentpage%>页 共<%=Records%>条记录 共<%=Pages%>页</p>
'以下部分固定套用,显示当前页前后5页的连接
<%
ii=currentpage-5
iii=currentpage+5
if ii < 1 then
ii=1
end if
if iii > pages then
iii=pages
end if
if currentpage > 6 then
%><a href="index0.asp?currentpage=1">1</a> ...<%
end if
for i=ii to iii
If i<>currentpage then
%><a href="index0.asp?currentpage=<%=i%>"><%=i%></a><%
else
%> <%=i%><br/> <%
end if
next
if pages > currentpage+5 then
%>... <a href="index0.asp?currentpage=<%=pages%>"><%=pages%></a><%
end if
%></p>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
如果碰到查询的可以
currentpage=cint(request("currentpage"))
if currentpage="" or currentpage<1 then
currentpage=1
currentpage=cint(currentpage)
end if
//首先对当前页面
set rs=server.CreateObject("adodb.recordset")
sql="select * from tableName where products_name like '%"&pname&"%'"
if author<>"" then
sql=sql&"and book_author_name = '"&author&"'"
end if
if isbn<>"" then
sql=sql&"and products_model='"&isbn&"'"
end if
'将所有搜索条件找齐
rs.open sql,conn,1,3
if rs.eof and rs.bof then str="没有商品"
response.write(str)
else
records=rs.recordcount 自动计算条树
pages=rs.pagecount 自动分页了
if currentpage>pages then
currentpage=pages
rs.absolutepage=currentpage
currentpage=1
records=0
pages=1
end if
end if
rs.close
'然后再来每个页面
if currentpage<>1 then
sql2 =sql&"order by products_id desc limit "&(currentpage-1)*10&",10"
end if
后面就跟上面一样了
<!-- #include file="conn.asp" -->
<%
const MaxPerPage=10
records=200
pages=records/maxperpage
if pages<1 then pages=1 end if
currentpage=cint(request("currentpage"))
if currentpage="" or currentpage<1 then
currentpage=1
if currentpage>pages then currentpage=pages
end if
set rs=server.createobject("adodb.recordset")
sql="select * from view_products order by products_id desc limit "&(currentpage-1)*MaxPerPage&","&MaxPerPage
Rs.CursorLocation = 3
rs.open sql,conn
%>
<p>
<%
j=1
do while (not rs.eof) and j<=MaxPerPage
%>
<a href="productlist.asp?products_id=<%=rs("products_id")%>"><%=((currentpage-1)*10+j)%>.<%=rs("products_name")%></a><br/>
<%
rs.movenext
j=j+1
loop
%>
第<%=currentpage%>页 共<%=Records%>条记录 共<%=Pages%>页</p>
'以下部分固定套用,显示当前页前后5页的连接
<%
ii=currentpage-5
iii=currentpage+5
if ii < 1 then
ii=1
end if
if iii > pages then
iii=pages
end if
if currentpage > 6 then
%><a href="index0.asp?currentpage=1">1</a> ...<%
end if
for i=ii to iii
If i<>currentpage then
%><a href="index0.asp?currentpage=<%=i%>"><%=i%></a><%
else
%> <%=i%><br/> <%
end if
next
if pages > currentpage+5 then
%>... <a href="index0.asp?currentpage=<%=pages%>"><%=pages%></a><%
end if
%></p>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
如果碰到查询的可以
currentpage=cint(request("currentpage"))
if currentpage="" or currentpage<1 then
currentpage=1
currentpage=cint(currentpage)
end if
//首先对当前页面
set rs=server.CreateObject("adodb.recordset")
sql="select * from tableName where products_name like '%"&pname&"%'"
if author<>"" then
sql=sql&"and book_author_name = '"&author&"'"
end if
if isbn<>"" then
sql=sql&"and products_model='"&isbn&"'"
end if
'将所有搜索条件找齐
rs.open sql,conn,1,3
if rs.eof and rs.bof then str="没有商品"
response.write(str)
else
records=rs.recordcount 自动计算条树
pages=rs.pagecount 自动分页了
if currentpage>pages then
currentpage=pages
rs.absolutepage=currentpage
currentpage=1
records=0
pages=1
end if
end if
rs.close
'然后再来每个页面
if currentpage<>1 then
sql2 =sql&"order by products_id desc limit "&(currentpage-1)*10&",10"
end if
后面就跟上面一样了