I have an approach to doing this that has always worked for me. I have done
this many ways over the years, but recently have found this to be the most
efficient. Lets assume the array we are making the table from is
@@local$tableArray, the number of cols is @@local$numCols:
<@! first figure the number of rows>
<@assign local$numTableRows
<@calc "ceil(<@numrows array=local$tableArray>/@@local$numCols)">>
<table>
<@! Create a counter to keep track of the Row number>
<@assign local$rowCounter 1>
<@! Loop for Rows>
<@for start=1 step=1 stop=@@local$numTableRows>
<tr>
<@! now loop for the cols>
<@for start=1 step=1 stop=@@local$numCols>
<td>
<@! Use if empty so empty fields show correctly>
<@ifempty "<@var local$tableArray[@@local$rowCounter,1]>">
<@else>
<@var local$tableArray[@@local$rowCounter,1]>
</@if>
</td>
<@! End of Col loop>
<@! Increment row Counter before reiterating>
<@assign local$rowCounter
<@calc"@@local$rowCounter + 1">>
</@for>
</tr>
</@for>
</table>
The key is to increment the counter inside the Column loop. This will keep
track of the tableArray row. Also, you must use the <@ifempty> method to
make sure the last few, possibly empty rows in the last column will display
correctly. This is a great method, because it is completely dynamic, you
just fill in the dimensions either statically or dynamically. This makes a
great tcf where you pass it an array and it kicks back a formatted table.
I simplified this a bunch from code I have written, so I hope there are no
mistakes.
--
Robert Garcia
BigHead Technology
21053 Devonshire Suite 206
Chatsworth, Ca 91311
Phone 818.773.8162
Fax 818.773.8164
http://www.bighead.net/
[EMAIL PROTECTED]
> From: Tom Carr <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Mon, 13 May 2002 14:18:12 -0500
> To: Multiple recipients of list witango-talk <[EMAIL PROTECTED]>
> Subject: Witango-Talk: Arranging a table vertically, not horizontally
>
> I am wanting to take the data coming out of a search and dynamically put the
> data in an html table vertically rather than horizontally like this:
>
> 1 6 11
> 2 7 12
> 3 8 13
> 4 9 14
> 5 10
>
>
> Rather than this:
> 1 2 3
> 4 5 6
> 7 8 9
> 10 11 12
> 13 14
>
> Anyone got a snippet to get me started here?
> I used to use the <MULTICOL> tag, but that is long since unsupported...
> Trying to recreate that functionality wiTango.
>
> Thx.
>
>
> --> [groundZER�]
> --> [t:o:m:c:a:r:r]
> --> [[EMAIL PROTECTED]]
> --> [847:757:4188]
>
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
> with unsubscribe witango-talk in the message body
>
________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
with unsubscribe witango-talk in the message body