Tables issue
am 11.05.2007 13:19:03 von John Peach
Not sure if this is the right place to post this, but sure someone will
kindly advise if it isn't
I have data from a SQL recordset that i want to display in a different
format, current code :
counter=0
for d= 1 to -int((-(ubound(bdata,2) +1))/3)
response.write "
"
for e= 1 to 3
for c=1 to 2
response.write ""
if counter >= ubound(bdata,2) then
response.write " "
else
response.write bdata(c,counter)
end if
response.write " | "
next 'c
counter =counter +1
next 'e
response.write "
"
next 'd
'next 'b
This write the array like
1 2 3
4 5 6
7 8
But i want to write the data like
1 4 7
2 5 8
3 6
Can anyone advise how to change the code to do this ?
Regards, with mental block
John
Re: Tables issue
am 11.05.2007 13:57:47 von northof40
On May 11, 11:19 pm, "John Peach" wrote:
> Not sure if this is the right place to post this, but sure someone will
> kindly advise if it isn't
>
> I have data from a SQL recordset that i want to display in a different
> format, current code :
>
> counter=0
> for d= 1 to -int((-(ubound(bdata,2) +1))/3)
> response.write ""
> for e= 1 to 3
>
> for c=1 to 2
> response.write ""
> if counter >= ubound(bdata,2) then
> response.write " "
> else
> response.write bdata(c,counter)
> end if
> response.write " | "
> next 'c
> counter =counter +1
> next 'e
> response.write "
"
> next 'd
>
> 'next 'b
>
> This write the array like
>
> 1 2 3
>
> 4 5 6
>
> 7 8
>
> But i want to write the data like
>
> 1 4 7
>
> 2 5 8
>
> 3 6
>
> Can anyone advise how to change the code to do this ?
>
> Regards, with mental block
>
> John
Let's get the disclaimers over with - it's very late where I am and
this code is completely untested *and* I can't completely understand
everything in your code ..... however I think the following will give
you enough of a flavour of what you could do to allow you to adapt it
to your own situation.
In essence you need to store the input data in an intemediate array
and then access the the 'columns' as if they were 'rows' and vica-
versa. In my code arrData is a the input data out of the database. I
store this temporarily in arrWork and then walk back over arrWork but
this time reversing the sense of 'columns' and 'rows'.
As I say it's completely untested but it might nudge you where you
need to go...
for iRow = 1 to UBound(arrData,2)
for iCol = 1 to 3
arrWork(iRow,iCol) = arrData(iRow,iCol)
iCounter = iRow
next iCol
next iRow
response.write ""
for iCol = 1 to 3
response.write ""
for iRow = 1 to iCounter
response.write "" & arrWork(iRow,iCol) & " | "
next iRow
response.write "
"
response.write "
"
Re: Tables issue
am 11.05.2007 14:04:07 von John Peach
Thanks for your reply, it has nudged me lol Have a good nights sleep :)
"northof40" wrote in message
news:1178884667.502337.208620@y80g2000hsf.googlegroups.com.. .
> On May 11, 11:19 pm, "John Peach" wrote:
>> Not sure if this is the right place to post this, but sure someone will
>> kindly advise if it isn't
>>
>> I have data from a SQL recordset that i want to display in a different
>> format, current code :
>>
>> counter=0
>> for d= 1 to -int((-(ubound(bdata,2) +1))/3)
>> response.write ""
>> for e= 1 to 3
>>
>> for c=1 to 2
>> response.write ""
>> if counter >= ubound(bdata,2) then
>> response.write " "
>> else
>> response.write bdata(c,counter)
>> end if
>> response.write " | "
>> next 'c
>> counter =counter +1
>> next 'e
>> response.write "
"
>> next 'd
>>
>> 'next 'b
>>
>> This write the array like
>>
>> 1 2 3
>>
>> 4 5 6
>>
>> 7 8
>>
>> But i want to write the data like
>>
>> 1 4 7
>>
>> 2 5 8
>>
>> 3 6
>>
>> Can anyone advise how to change the code to do this ?
>>
>> Regards, with mental block
>>
>> John
>
> Let's get the disclaimers over with - it's very late where I am and
> this code is completely untested *and* I can't completely understand
> everything in your code ..... however I think the following will give
> you enough of a flavour of what you could do to allow you to adapt it
> to your own situation.
>
> In essence you need to store the input data in an intemediate array
> and then access the the 'columns' as if they were 'rows' and vica-
> versa. In my code arrData is a the input data out of the database. I
> store this temporarily in arrWork and then walk back over arrWork but
> this time reversing the sense of 'columns' and 'rows'.
>
> As I say it's completely untested but it might nudge you where you
> need to go...
>
> for iRow = 1 to UBound(arrData,2)
> for iCol = 1 to 3
> arrWork(iRow,iCol) = arrData(iRow,iCol)
> iCounter = iRow
> next iCol
> next iRow
>
> response.write ""
> for iCol = 1 to 3
> response.write ""
> for iRow = 1 to iCounter
> response.write "" & arrWork(iRow,iCol) & " | "
> next iRow
> response.write "
"
> response.write "
"
>
>