Results 1 to 5 of 5

Thread: --SOLVED--Display records many columns on same page ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose
    Posts
    276

    Question --SOLVED--Display records many columns on same page ?

    i.e, I have 200 employee names that get from database. I design my page with 3 columns. I want to display 20 employees in 1st column, and the rest should go next columns in same page. If there are records left, it should go to next page. Is it possible to do that ? Please let me know if you know how to do that. Thanks in advance.
    Last edited by learnervb; Apr 3rd, 2003 at 02:31 PM.
    Tiny Mickey

  2. #2
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    Yes it's possible, but you have to use an array to store all names in array first. You need to do it because table builds row by row from top to buttom, but you ask to do it column by column from left to right.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose
    Posts
    276
    So how to store data from column to column ?
    Tiny Mickey

  4. #4
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    Here is an example. Try to break it down by 200 names per page by yourself.
    Code:
    <html>
    <head>
    <title>Names</title>
    </head>
    <body>
    <%Dim arrNames(), rs, cn, sql, arrIndex, rec_count, rec_interval
    on error resume next
    
    cn="Driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("../db/credential.mdb")
    sql="SELECT DISTINCT (LastName) as fName FROM tbl_Name ORDER BY LastName ASC"
    set rs=server.createobject("ADODB.Recordset")
    rs.cachesize=5
    rs.cursorlocation=3
    rs.open sql, cn,0,2
    
    rec_count=rs.recordcount
    rec_interval=int(rec_count/3)
    
    response.write "<b>Records Found: " & rec_count & "</b>"
    
    if not rs.eof then
    	arrIndex=0
    	do until rs.eof
    		ReDim Preserve arrNames(arrIndex)
    		arrNames(arrIndex)=rs("fName")
    		rs.movenext
    		arrIndex=arrIndex+1
    	loop
    end if
    
    rs.close
    set rs=nothing
    
    response.write "<table>"
    for j=0 to rec_interval
    	response.write "<tr>"
    	response.write "<td>" & j+1 & ". " & arrNames(j) & "</td>"
    	response.write "<td>" & j+rec_interval+2 & ". " & arrNames(j+rec_interval+1) & "</td>"
    	response.write "<td>" & j+(rec_interval*2)+3 & ". " & arrNames(j+(rec_interval*2)+2) & "</td>"
    	response.write "</tr>"
    next
    response.write "</table>"
    %>
    </body>
    </html>

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose
    Posts
    276
    Thanks andreys. It worked.
    Tiny Mickey

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width