Tables issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Peach

    Tables issue

    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

    #2
    Re: Tables issue

    On May 11, 11:19 pm, "John Peach" <john.pe...@zen .co.ukwrote:
    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,iC ol) = arrData(iRow,iC ol)
    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,iC ol) & "</td>"
    next iRow
    response.write "</tr>"
    response.write "</table>"


    Comment

    • John Peach

      #3
      Re: Tables issue

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

      "northof40" <shearichard@gm ail.comwrote in message
      news:1178884667 .502337.208620@ y80g2000hsf.goo glegroups.com.. .
      On May 11, 11:19 pm, "John Peach" <john.pe...@zen .co.ukwrote:
      >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,iC ol) = arrData(iRow,iC ol)
      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,iC ol) & "</td>"
      next iRow
      response.write "</tr>"
      response.write "</table>"
      >
      >

      Comment

      Working...