Getting a correctly formatted table from a GetRows array

Hi All

Somebody kindly sent me a routine to do this sometime ago, but for the life
of me I can't work out how it works and would prefer to use a simpler method
so that I can resolve any future issues with it.

Basically I have an array populated from a recordset getrows and I want to
create a nicely formatted table of this data with all of the right columns.

If my array consists of 8 rows of data and I want my table to display this
array 3 columns wide then the routine needs to make sure that it drops the
array rows onto enough table rows to show them all, eg:

< data1 > < data1 > < data1 >
< data1 > < data1 > < data1 >
< data1 > < data1 > < create the <TD></TD> bit but obviously leave it
blank >

Any help you can give would be very much appreciated.

The code I currently use, but don't understand is as follows:

Response.Write "<TABLE CELLSPACING=0 CELLPADDING=0 CLASS='ProdFullDesc'
BORDER=0>"

intArrayCount = UBound(arrSQLData,2)
intStartRow = 1

IF intArrayCount mod 3 = 0 THEN
intColDiff = CInt(intArrayCount \ 3)
ELSE
intColDiff = CInt(intArrayCount \ 3) + 1
END IF

FOR x = 1 TO intColDiff
Response.Write "<TR>"
intTargetRow = intStartRow
z=0

FOR y = 0 to intArrayCount
IF y = intTargetRow-1 THEN
Response.Write "<TD ALIGN='CENTER'><IMG SRC='"
Response.Write cImageGalleryFolderPath & arrSQLData(0,y) & "'
BORDER=0><BR>"
Response.Write arrSQLData(1,y) & "</TD>"
intTargetRow = intTargetRow + intColDiff
END IF
NEXT

Response.Write "</TR><TR><TD COLSPAN=" & intColDiff & "
HEIGHT=10></TD></TR>"
intStartRow = intStartRow + 1
NEXT

Response.Write "</TABLE><BR>"
Laphan [ Di, 29 November 2005 22:05 ] [ ID #1079788 ]

Re: Getting a correctly formatted table from a GetRows array

Laphan wrote on 29 nov 2005 in microsoft.public.inetserver.asp.db:

> Hi All
>
> Somebody kindly sent me a routine to do this sometime ago, but for the
> life of me I can't work out how it works and would prefer to use a
> simpler method so that I can resolve any future issues with it.
>
> Basically I have an array populated from a recordset getrows and I
> want to create a nicely formatted table of this data with all of the
> right columns.
>
> If my array consists of 8 rows of data and I want my table to display
> this array 3 columns wide then the routine needs to make sure that it
> drops the array rows onto enough table rows to show them all, eg:
>
> < data1 > < data1 > < data1 >
> < data1 > < data1 > < data1 >
> < data1 > < data1 > < create the <TD></TD> bit but obviously leave
> it
>blank >
>
> Any help you can give would be very much appreciated.
>
> The code I currently use, but don't understand is as follows:
>
> Response.Write "<TABLE CELLSPACING=0 CELLPADDING=0
> CLASS='ProdFullDesc' BORDER=0>"
>
> intArrayCount = UBound(arrSQLData,2)
> intStartRow = 1
>
> IF intArrayCount mod 3 = 0 THEN
> intColDiff = CInt(intArrayCount \ 3)
> ELSE
> intColDiff = CInt(intArrayCount \ 3) + 1
> END IF
>
> FOR x = 1 TO intColDiff
> Response.Write "<TR>"
> intTargetRow = intStartRow
> z=0
>
> FOR y = 0 to intArrayCount
> IF y = intTargetRow-1 THEN
> Response.Write "<TD ALIGN='CENTER'><IMG SRC='"
> Response.Write cImageGalleryFolderPath & arrSQLData(0,y) & "'
> BORDER=0><BR>"
> Response.Write arrSQLData(1,y) & "</TD>"
> intTargetRow = intTargetRow + intColDiff
> END IF
> NEXT
>
> Response.Write "</TR><TR><TD COLSPAN=" & intColDiff & "
> HEIGHT=10></TD></TR>"
> intStartRow = intStartRow + 1
> NEXT
>
> Response.Write "</TABLE><BR>"

The use of different counters confuses the issue,
I use one counter and calculate from there.
Not using response.write clears things up for me(!!).

Try this :


<%
count = UBound(theArray,2)
maxRows = int((count+1)/3+0.9)
%>

<table border=1>

<%
for rows = 0 to maxRows-1
%>

<tr>

<%
for cols = 0 to 2
y = rows + cols*maxRows
if y < count+1 then
%>

<td>
<img src='<%=Path & theArray(0,y)%>'>
<br>
<%=theArray(1,y)%>
</td>

<%
else
%>

<td> </td>

<%
end if
next
%>

</tr>

<%
next
%>

</table>





--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
exjxw.hannivoort [ Di, 29 November 2005 23:26 ] [ ID #1079789 ]

Re: Getting a correctly formatted table from a GetRows array

Evertjan. wrote on 29 nov 2005 in microsoft.public.inetserver.asp.db:

> I use one counter and calculate from there.

Sorry, two counters, rows and cols

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
exjxw.hannivoort [ Di, 29 November 2005 23:27 ] [ ID #1079790 ]

Re: Getting a correctly formatted table from a GetRows array

Many thanks Evertjan


"Evertjan." <exjxw.hannivoort [at] interxnl.net> wrote in message
news:Xns971DEE9CF1B3Ceejj99 [at] 194.109.133.242...
Evertjan. wrote on 29 nov 2005 in microsoft.public.inetserver.asp.db:

> I use one counter and calculate from there.

Sorry, two counters, rows and cols

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Oliver Weichhold [ Mi, 30 November 2005 10:37 ] [ ID #1081587 ]
Webserver » microsoft.public.inetserver.asp.db » Getting a correctly formatted table from a GetRows array

Vorheriges Thema: Oracle Connection
Nächstes Thema: Q: about returned records from MDB