IIS ASP - Tables issue

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > May 2007 > Tables issue





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Tables issue
John Peach

2007-05-11, 7:17 am

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 "<tr>"
for e= 1 to 3

for c=1 to 2
response.write "<td class='a'>"
if counter >= ubound(bdata,2) then
response.write "&nbsp;"
else
response.write bdata(c,counter)
end if
response.write "</td>"
next 'c
counter =counter +1
next 'e
response.write "</TR>"
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


northof40

2007-05-11, 7:17 am

On May 11, 11:19 pm, "John Peach" <john.pe...@zen.co.uk> 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 "<tr>"
> for e= 1 to 3
>
> for c=1 to 2
> response.write "<td class='a'>"
> if counter >= ubound(bdata,2) then
> response.write "&nbsp;"
> else
> response.write bdata(c,counter)
> end if
> response.write "</td>"
> next 'c
> counter =counter +1
> next 'e
> response.write "</TR>"
> 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 "<table>"
for iCol = 1 to 3
response.write "<tr>"
for iRow = 1 to iCounter
response.write "<td>" & arrWork(iRow,iCol) & "</td>"
next iRow
response.write "</tr>"
response.write "</table>"


John Peach

2007-05-11, 1:17 pm

Thanks for your reply, it has nudged me lol Have a good nights sleep

"northof40" <shearichard@gmail.com> wrote in message
news:1178884667.502337.208620@y80g2000hsf.googlegroups.com...
> On May 11, 11:19 pm, "John Peach" <john.pe...@zen.co.uk> wrote:
>
> 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 "<table>"
> for iCol = 1 to 3
> response.write "<tr>"
> for iRow = 1 to iCounter
> response.write "<td>" & arrWork(iRow,iCol) & "</td>"
> next iRow
> response.write "</tr>"
> response.write "</table>"
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com