<% on error resume next '分頁程序 function fy(scount,pgsize,pg,url) 'scount記錄總數 'pgsize每面記錄數 'pg當前頁 'url轉向的地址,運行本函數后會在后面加上"&page=頁號" dim pgcount,i,j,mh,k mh=chr(34) '不好意思,是雙引號
'cint()會四舍五入,所以不得不加個k k=(scount+pgsize-1)/pgsize pgcount=cint((scount+pgsize-1)/pgsize) if pgcount>k then pgcount=pgcount-1
response.write "<a href="+mh+url+"&page=1"+mh+">[第一頁]</a> " if cint(pg)>cint(1) then response.write "<a href="+mh+url+"&page="+cstr(pg-1)+mh+">[上一頁]</a> " end if if cint(pg)>5 then i=cint(pg)-5 else i=1 end if
if cint(pgcount)<cint(pg+5) then j=pgcount else j=pg+5 end if
while cint(i)<=cint(j) if cint(i)=cint(pg) then response.write cstr(i)+" " else response.write "<a href="+mh+url+"&page="+cstr(i)+mh+">"+cstr(i)+"</a> " end if i=i+1 wend
if cint(pgcount)>cint(pg) then response.write "<a href="+mh+url+"&page="+cstr(pg+1)+mh+">[下一頁]</a> " end if
response.write "<a href="+mh+cstr(url)+"&page="+cstr(pgcount)+mh+">[最后頁]</a> "
end function %>
|