asp通用分页函数

 

 1<%dim rs3,pm3,bg
 2page=clng(request("page"))
 3set rs3 = server.createobject("adodb.recordset")
 4sql3 = "select distinct brlword from userinfo where bfenshuduan='"&key&"' order by brlword"
 5rs3.open sql3,conn,1,1
 6if rs3.eof then
 7%>
 8    <tr>
 9      <td width="580" colspan="5">
10    <p align="center"><font color="#FF0000">对不起,没有符合条件的高校!</font>
11
12      </td>
13    </tr>
14    <tr>
15     <td width="580" colspan="5">
16<else %>
17<%
18const maxperpage=1
19dim currentpage
20rs3.pagesize=maxperpage
21currentpage=request.querystring("pageid")
22if currentpage="" then
23currentpage=1
24elseif currentpage<1 then
25currentpage=1
26else
27currentpage=clng(currentpage)
28    if currentpage > rs3.pagecount then
29    currentpage=rs3.pagecount
30    end if
31end if
32
33if not isnumeric(currentpage) or currentpage="" then
34currentpage=1
35end if
36dim totalput,n
37totalput=rs3.recordcount
38if totalput mod maxperpage=0 then
39n=totalput\maxperpage
40else
41n=totalput\maxperpage+1
42end if
43if n=0 then
44n=1
45end if
46rs3.move(currentpage-1)*maxperpage
47i=0
48do while i< maxperpage and not rs3.eof
49        %>
50        <tr>
51        <td><%=getschoolinfo(rs3("brlword"),1)%></td>
52        <td><%=getschoolinfo(rs3("brlword"),2)%></td>
53        <td><%=getschoolinfo(rs3("brlword"),5)%></td>
54        <td><%=getschoolinfo(rs3("brlword"),3)%></td>
55        <td><%=getschoolinfo(rs3("brlword"),4)%></td>
56      </tr>
57<%                                                                         
58i=i+1                                                      
59rs3.movenext                                                        
60loop                                                                                 
61                                    
62%>   
63    </table>
64<p align="center">页数:<%=currentpage%>/<=n%>                                                       
65       <%k=currentpage                                                                                
66       if k<>1 then%>                                                            
67       <a href="picitop2.asp?pageid=1">首页</a>                                                                                
68       <a href="picitop2.asp?pageid=<%=k-1%>&key=<%=key%>">上一</a>                                                                                
69       <%else%>                                                            
70       首页 上一页                                                                                
71       <%end if%>                                                            
72       <%if k<>then%>                                                                                
73       <a href="picitop2.asp?pageid=<%=k+1%>&key=<%=key%>">下一</a>                                                                                
74       <a href="picitop2.asp?pageid=<%=n%>&key=<%=key%>">尾页</a>                                                                                
75       <%else%>                                                            
76       下一页 尾页                                                                                
77       <%end if%>                                                            
78     共为您找到<font color="red"><%=totalput%></font>所高校
79 
posted @ 2005-07-10 18:32  拼博之路  阅读(641)  评论(2编辑  收藏  举报