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

一段生成列表的子程序

本帖由 Ulysses2006-10-13 发布。版面名称:后端开发

  1. Ulysses

    Ulysses New Member

    注册:
    2006-02-05
    帖子:
    10,018
    赞:
    16
    PHP:
    Sub GetListExt(sql_1sql_2output_1output_2opentagclosetagrowcol)
        
    Dim recordcountpagesizepagecountabsolutepageij
        
        recordcount 
    conn.Execute(sql_1)(0)
        
        If 
    row <= 0 Then row 1
        
    If col <= 0 Then col 1
        
        pagesize 
    row col
        
        
    If recordcount 0 Then
    '        If pagesize = "" Or IsEmpty(pagesize) Or IsNull(pagesize) Then
    '            
    pagesize 30
    '        Else
    '            
    pagesize CID(pagesize)
    '        End If
        
            If recordcount Mod pagesize <> 0 Then
                pagecount = Int(recordcount / pagesize) + 1
            Else
                pagecount = recordcount / pagesize
            End If
        
            absolutepage = CID(Request.QueryString("Page"))
            If absolutepage = 0 Then absolutepage = 1
            If absolutepage > pagecount Then absolutepage = pagecount
        
            i = 0
            
            Dim rs, e, s
            Set rs = Server.CreateObject("ADODB.Recordset")
            rs.Open sql_2, conn, 1, 1
            rs.PageSize = pagesize
            rs.AbsolutePage = absolutepage
            Do While Not rs.BOF And Not rs.EOF And i < pagesize
                If i Mod col = 0 Then Response.Write(opentag)
            
                j = 0
                s = output_1
                For Each e In rs.Fields
                    s = Replace(s, "{" & j & "}", NullToSpace(rs.Fields(e.Name)))
                    j = j + 1
                Next
                Response.Write(s)
                
                If i Mod col = col - 1 Then Response.Write(closetag & vbCrLf)
                i = i + 1
                rs.MoveNext
            Loop
            rs.Close
            Set rs = Nothing
            
            If i Mod col <> 0 Then
                Do While i Mod col <> 0
                    s = output_2
                    
                    Dim k
                    For k = 0 To j
                        s = Replace(s, "{" & k & "}", "")
                    Next
                    
                    Response.Write(s)
                    
                    i = i + 1
                Loop
                
                Response.Write(closetag & vbCrLf)
            End If
        Else
            Response.Write("<p align=""center"">没有找到满足要求的记录。</p>" & vbCrLf)
            Exit Sub
        End If
    End Sub
     
  2. 西子宜

    西子宜 Well-Known Member

    注册:
    2005-09-05
    帖子:
    15,739
    赞:
    62
    怎么用
     
  3. srsman

    srsman Active Member

    注册:
    2005-11-08
    帖子:
    1,920
    赞:
    6
    怎么有点像讯雷BLOG上的代码。。。。。。。。
     
  4. 西子宜

    西子宜 Well-Known Member

    注册:
    2005-09-05
    帖子:
    15,739
    赞:
    62
    .....
     
  5. tzy

    tzy New Member

    注册:
    2005-11-04
    帖子:
    113
    赞:
    3
    么样用啊