|
-
Apr 2nd, 2003, 07:43 PM
#1
Thread Starter
Hyperactive Member
--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
-
Apr 2nd, 2003, 08:20 PM
#2
Frenzied Member
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.
-
Apr 2nd, 2003, 08:34 PM
#3
Thread Starter
Hyperactive Member
So how to store data from column to column ?
-
Apr 2nd, 2003, 09:34 PM
#4
Frenzied Member
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>
-
Apr 3rd, 2003, 02:31 PM
#5
Thread Starter
Hyperactive Member
Thanks andreys. It worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|