Groups | Blog | Home
all groups > inetserver asp db > november 2005 >

inetserver asp db : Getting a correctly formatted table from a GetRows array


Laphan
11/29/2005 9:05:23 PM
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>"

Evertjan.
11/29/2005 10:26:15 PM
Laphan wrote on 29 nov 2005 in microsoft.public.inetserver.asp.db:

[quoted text, click to view]

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>&nbsp;</td>

<%
end if
next
%>

</tr>

<%
next
%>

</table>





--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Evertjan.
11/29/2005 10:27:22 PM
Evertjan. wrote on 29 nov 2005 in microsoft.public.inetserver.asp.db:

[quoted text, click to view]

Sorry, two counters, rows and cols

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Astra
11/30/2005 9:37:59 AM
Many thanks Evertjan


[quoted text, click to view]
Evertjan. wrote on 29 nov 2005 in microsoft.public.inetserver.asp.db:

[quoted text, click to view]

Sorry, two counters, rows and cols

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

AddThis Social Bookmark Button