|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
[ASP]关于N行M列的分页问题?
<%
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
dim rs
dim sql
if not isempty(request("selAnnounce")) then
idlist=request("selAnnounce")
if instr(idlist,",")>0 then
dim idarr
idArr=split(idlist)
dim id
for i = 0 to ubound(idarr)
id=clng(idarr(i))
call deleteannounce(id)
next
else
call deleteannounce(clng(idlist))
end if
end if
id=request("id")
set rs=server.createobject("adodb.recordset")
sql="select * from ** order by ID desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'>对不起,没有您要查询的信息</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent totalput,MaxPerPage
showpage totalput,MaxPerPage,"list.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent totalput,MaxPerPage
showpage totalput,MaxPerPage,"list.asp"
else
currentPage=1
showContent totalput,MaxPerPage
showpage totalput,MaxPerPage,"list.asp"
end if
end if
rs.close
end if
set rs=nothing
sub showContent (totalput,MaxPerPage)
%>
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<%
do while not rs.bof and not rs.eof ' then
For j = 1 to 9
I=I-1
if (j mod 3=1) then
response.write "<tr>"
end if
%>
<TD>
<a href="news_show.asp?daihao=<%=rs("id")%>" id="content"><%=rs("title")%></A>
</TD>
<%
if (j mod 3 = 0) then
response.write "</tr>"
end if
'i=i+1
'if i>=MaxPerPage then exit do
rs.movenext
loop
'next
'else
%>
<tr><td>没有任何记录</td></tr>
<%
'end if
%>
</table>
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td>
<%
end sub
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
if CurrentPage<2 then
response.write "<table border=0 width=600 cellspacing=0 cellpadding=0 bgcolor=#e8f4ff>"
response.write "<tr height=30>"
response.write "<td align=left>"
response.write "共<font color=#ff6600><b>"&n&"</b></font>页 第<font color=#ff6600><b>"&CurrentPage&"</b></font>页 共检索到<font color=#ff6600><b>"&totalnumber&"</b></font>条相关信息</td>"
response.write "<td align=right>"
response.write "【最前页】【上一页】"
else
response.write "<table border=0 width=600 cellspacing=0 cellpadding=0 bgcolor=#e8f4ff>"
response.write "<tr height=30>"
response.write "<td align=left>"
response.write "共<font color=#ff6600><b>"&n&"</b></font>页 第<font color=#ff6600><b>"&CurrentPage&"</b></font>页 共检索到<font color=#ff6600><b>"&totalnumber&"</b></font>条相关信息</td>"
response.write "<td align=right>"
response.write "【<a href="&filename&"?page=1&id="&id&"&txtitle="&request("txtitle")&">最前页</a>】"
response.write "【<a href="&filename&"?page="&CurrentPage-1&"&id="&id&"&txtitle="&request("txtitle")&">上一页</a>】 "
end if
if n-currentpage<1 then
response.write "【下一页】【最后页】"
else
response.write "【<a href="&filename&"?page="&(CurrentPage+1)&"&id="&id&"&txtitle="&request("txtitle")&">"
response.write "下一页</a>】【<a href="&filename&"?page="&n&"&id="&id&"&txtitle="&request("txtitle")&">最后页</a>】"
end if
response.write "</td>"
response.write "</tr>"
response.write "</table>"
response.write "</form>"
end function
%></td>
</tr>
</table>
上面的怎么没有分页的功能呢? |
斑竹能来解释一下吗? |
|