1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

发一分页程序。。

本帖由 小叶 于 2006-04-07 发布。版面名称:后端开发

  1. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    PHP:
    Function JoinChar(strUrl)
            if 
    strUrl="" then
                JoinChar
    =""
                
    Exit Function
            
    end if
            if 
    InStr(strUrl,"?")<len(strUrl) then 
                
    if InStr(strUrl,"?")>1 then
                    
    if InStr(strUrl,"&")<len(strUrl) then 
                        JoinChar
    =strUrl & "&"
                    
    else
                        
    JoinChar=strUrl
                    end 
    if
                else
                    
    JoinChar=strUrl & "?"
                
    end if
            else
                
    JoinChar=strUrl
            end 
    If
    End Function

    Function 
    ShowPage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
            
    dim n, i,strTemp,strUrl
            
    if totalnumber mod maxperpage=0 then
                n
    = totalnumber \ maxperpage
            
    else
                
    n= totalnumber \ maxperpage+1
            end 
    if
            
    strTemp= "<table align=""center""><tr><td>"
            
    if ShowTotal=true then 
                strTemp
    =strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
            
    end if
            if 
    CreateHtmlIng=True then
                  
    if CurrentPage<2 then
                    strTemp
    =strTemp & "首页 上一页&nbsp;"
                
    else
                    
    strTemp=strTemp & "<a href="""&PreFixion&"_"&DefaultPage&"."&Cl.CreateFileExt&""">首页</a>&nbsp;"
                    
    if (CurrentPage-1)=1 then
                        strTemp
    =strTemp & "<a href="""&PreFixion&"_"&DefaultPage&"."&Cl.CreateFileExt&""">上一页</a>&nbsp;"
                    
    else
                        
    strTemp=strTemp & "<a href="""&PreFixion&"_List_" & (CurrentPage-1) & "."&Cl.CreateFileExt&""">上一页</a>&nbsp;"
                    
    end if
                
    end if
                if 
    n-currentpage<1 then
                    strTemp
    =strTemp & "下一页 尾页"
                
    else
                    
    strTemp=strTemp & "<a href="""&PreFixion&"_List_" & (CurrentPage+1) & "."&Cl.CreateFileExt&""">下一页</a>&nbsp;"
                    
    strTemp=strTemp & "<a href="""&PreFixion&"_List_" & n & "."&Cl.CreateFileExt&""">尾页</a>"
                  
    end if
                
    strTemp=strTemp & "&nbsp;页次:<strong><font color=""red"">" & CurrentPage & "</font>/" & n & "</strong>页 "
                
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
                
    if ShowAllPages=True then
                    strTemp
    =strTemp & "&nbsp;转到:<select name=""page"" size=""1"" onchange=""javascript:window.location=''+this.options[this.selectedIndex].value;"">"
                    
    strTemp=strTemp & "<option value="""&PreFixion&"_"&DefaultPage&"."&Cl.CreateFileExt&""">第" & 1 & "页</option>"
                    
    for i = 2 to n
                        strTemp
    =strTemp & "<option value="""&PreFixion&"_List_" & i & "."&Cl.CreateFileExt&""""
                        
    if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
                        
    strTemp=strTemp & ">第" & i & "页</option>"
                    
    next
                    strTemp
    =strTemp & "</select>"
                
    end if
            else
                
    strUrl=JoinChar(sfilename)
                  if 
    CurrentPage<2 then
                    strTemp
    =strTemp & "首页 上一页&nbsp;"
                
    else
                    
    strTemp=strTemp & "<a href=""" & strUrl & "page=1"">首页</a>&nbsp;"
                    
    strTemp=strTemp & "<a href=""" & strUrl & "page=" & (CurrentPage-1) & """>上一页</a>&nbsp;"
                
    end if
                if 
    n-currentpage<1 then
                    strTemp
    =strTemp & "下一页 尾页"
                
    else
                    
    strTemp=strTemp & "<a href=""" & strUrl & "page=" & (CurrentPage+1) & """>下一页</a>&nbsp;"
                    
    strTemp=strTemp & "<a href=""" & strUrl & "page=" & n & """>尾页</a>"
                  
    end if
                
    strTemp=strTemp & "&nbsp;页次:<strong><font color=""red"">" & CurrentPage & "</font>/" & n & "</strong>页 "
                
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
                
    if ShowAllPages=True then
                    strTemp
    =strTemp & "&nbsp;转到:<select name=""page"" size=""1"" onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"   
                    
    for i = 1 to n   
                        strTemp
    =strTemp & "<option value=""" & i & """"
                        
    if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
                        
    strTemp=strTemp & ">第" & i & "页</option>"   
                    
    next
                    strTemp
    =strTemp & "</select>"
                
    end if
            
    end if
            
    strTemp=strTemp & "</td></tr></table>"
            
    ShowPage=strTemp
        End 
    Function
     
  2. amao

    amao New Member

    注册:
    2005-12-12
    帖子:
    43
    赞:
    0
    我完全蒙了,和我平时看的格式不一样,一开始还以为是PHP5的,细细想来,应该是另外一种格式
     
  3. 风狼

    风狼 New Member

    注册:
    2005-10-01
    帖子:
    7,452
    赞:
    25
    好多看不懂的代码捏~~~
     
  4. 风狼

    风狼 New Member

    注册:
    2005-10-01
    帖子:
    7,452
    赞:
    25
    呀哦~我比楼上强~我看懂了这是ASP的
     
  5. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    hoho~~。。asp的,高亮了,比较舒服。
     
  6. 风狼

    风狼 New Member

    注册:
    2005-10-01
    帖子:
    7,452
    赞:
    25
    唉~分页我一直没弄明白~所以看不懂。连url怎么传递的都没想通
     
  7. erentan

    erentan New Member

    注册:
    2006-04-07
    帖子:
    6
    赞:
    0
    偶来发一个ASP的