PDA

View Full Version : Sort of records in a Table view.


NinjaTurtle
01-19-2004, 05:08 AM
Dear,

i have 20 records, i want them to display in a table view with 2 columns and 10 rows for each, but the must follow the number of sorting, example:

1. a 11. k
2. b 12. l
3. c 13. m
4. d 14. n
5. e 15. o
6. f 16. p
7. g 17.q
8. h 18. r
9. i 19. s
10. j 20. t

wat i did is:

1. a 2. b
3. c 4. d
...

19. s 20. t

My source

i=1

Do while Not rs.eof
D= (i mod 2)
E=(i+1 mod 2)

if (D=1) then
response.write "<tr>"
end if
response.write "<td>"&i&". </td><td><input name='minu"&i&"' type='checkbox' value='1'> "&rs("fname")&"</td>"& vbcrlf
if (E = 1) then
response.write "</tr>"
end if

i=i+1
rsstaffOption.movenext
loop

M@rco
01-19-2004, 12:59 PM
Let me get this straight... rather than display records sequentially from left to right in rows, you want to show them vertically in columns?

If so, you need to grab all the data into an array with GetRows(), and then pull out the required records as you draw the table row-by-row.

HINTS:
- Think about how you as a human would pull out the right records from the array to come up with the generic equation that lets you retrieve out the required record given N records, X columns, Y rows, and the position in the grid to be retrieved (column A, row B). Whether X or Y are calculated or are constants is entirely up to you, but it's best to make your equation generic and define those variables elsewhere.

- Don't forget to compensate for the fact that arrays start at index 0 (do that as a final touch).

- You might want to implement paging too, in which you should precalculate the number of pages (based on a constant defining the max. no. of records per page), and the remainder (if any) on the last page).


Have a go yourself (it's not hard), and if you get stuck, post what you've got so far and I'll help you.

;)

NinjaTurtle
01-20-2004, 02:24 AM
Dear,

Thanks a lot....
i will try it... thanks with ur advice.