1 回答

TA貢獻1890條經(jīng)驗 獲得超9個贊
這個是最好的ASP ACCESS的分頁。
set rs = conn.execute("select count(m_id) as HH_sum_vote_log from HH_say "&HS_haveid2&"")
HH_sum_vote_log = rs("HH_sum_vote_log")
rs.close
set rs = nothing
if HH_sum_vote_log>0 then
HH_sum_page_result=Round(HH_sum_vote_log/HH_pagesize,2)
HH_sum_page=cint(HH_sum_vote_log/HH_pagesize)
if HH_sum_page<HH_sum_page_result then
HH_sum_page=HH_sum_page+1
end if
else
HH_sum_page=1
end if
if isnumeric(HH_admpg) = false then
echo ("頁碼有誤,將為您轉(zhuǎn)向第一頁!")
end if
if HH_admpg="" or HH_admpg<1 then
page = 1
else
page = cint(HH_admpg)
end if
if page < 1 or page > HH_sum_page then
echo ("頁碼有誤,將為您轉(zhuǎn)向第一頁!")
end if
HH_sumpagemax="desc"
if page=HH_sum_page and page<>1 and HH_sum_page<>1 then
HH_pagesize_no=(HH_pagesize*HH_sum_page)-HH_sum_vote_log
if not HH_pagesize_no=0 then
HH_pagesize=HH_pagesize-HH_pagesize_no
HH_sumpagemax="asc"
end if
end if
set rs=server.createobject("adodb.recordset")
sql = "select * from (select top "&HH_pagesize&" * from (select top "&page*HH_pagesize&" * from HH_say "&HS_haveid&" order by Val([m_id]) "&HH_sumpagemax&") order by Val([m_id])) order by Val([m_id]) desc"
rs.open sql,conn,1,1
if rs.eof then
echo ("<script language='javascript'>alert('本項目沒有訪客留言,請返回!');window.history.go(-1);</script>")
rs.close
set rs=nothing
exit sub
end if
do while not rs.eof
rs.movenext
loop
<div id="H_page">第<%=page%>/<%=HH_sum_page%>頁 共<%=HH_sum_vote_log%>條記錄<%
if page=1 then%>
首頁
<%else%>
<a href="?class=<%=HH_admclass%><%=HH_idshow%>&pg=1" id="lianjie" class="zw">首頁</a>
<%end if
if page<>1 then
%>
<a href="?class=<%=HH_admclass%><%=HH_idshow%>&pg=<%=page-1%>" id="lianjie" class="zw">上一頁</a>..
<%else%>
上一頁
<%end if
pg_px_top=page-5
pg_px_botton=page+5
for i=pg_px_top to pg_px_botton
if i<1 or i>HH_sum_page then
else
if i=page then
response.write i
else%>
<a href="?class=<%=HH_admclass%><%=HH_idshow%>&pg=<%=i%>"><%=i%></a>
<% end if
end if
next
if page<>HH_sum_page then
%>
..<a href="?class=<%=HH_admclass%><%=HH_idshow%>&pg=<%=page+1%>" id="lianjie" class="zw">下一頁</a>
<%else%>
下一頁
<%end if
if page<>HH_sum_page then%>
<a href="?class=<%=HH_admclass%><%=HH_idshow%>&pg=<%=HH_sum_page%>" id="lianjie" class="zw">尾頁</a>
<%else%>
尾頁
<%end if
echo ("</div>")
rs.close
set rs=nothing
%>
目前最好的ASP ACCESS分頁法,無償奉獻