Array information into 2 cells instead of 1?

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

    Array information into 2 cells instead of 1?

    ok.. subject may not have been clear. I have an array that is being
    split - each line into 2 areas. Those 2 areas of each line will take
    up one table cell, i.e.:

    <TD>$item1 $item2</TD>

    So far, so good. Now, when pulling from my db.. I have many lines (100
    so far.. soon to be more), I want to have 2 cells so the page fills a
    bit more.. how do I set it to put line 1 info in cell 1, line 2 info
    in cell 2, and go back & forth between through the db?

    foreach $i (@indata)
    {chomp($i);

    ($sponsor,$othe r) = split(/\|/,$i);
    if ($other eq "")
    {$add = "";
    $add2="";}
    else
    {$add = "<SPAN CLASS=\"ltblue2 \">";
    $add2 = "</SPAN>";}

    print "<TR>\n";
    print "<TD CLASS=\"ltblue\ ">$sponsor $add$other$add2 </TD><TD
    CLASS=\"ltblue\ ">$sponsor$add$ other$add2</TD>\n";
    print "</TR>\n";}

    what should change to make cell 2 have the info that currently goes
    to row 2 (as it is.. it just repeats the same db line of info in both
    cells.. obviously <G> )

    tia,
    -L
  • Gunnar Hjalmarsson

    #2
    Re: Array information into 2 cells instead of 1?

    Laurey wrote:[color=blue]
    > how do I set it to put line 1 info in cell 1, line 2 info
    > in cell 2, and go back & forth between through the db?[/color]

    Simply use a couple of extra check variables. Suggested additions and
    changes below is an example.

    my $cnt = 0;
    my $tot = @indata;
    my $odd = $tot % 2;
    my $col = 0;
    [color=blue]
    > foreach $i (@indata)[/color]

    <snip>
    [color=blue]
    > $add2 = "</SPAN>";}[/color]


    $col = $col == 1 ? 2 : 1;
    $cnt++;

    print "<TR>\n" if $col == 1;
    print "<TD CLASS=\"ltblue\ ">$sponsor $add$other$add2 </TD>";
    print "<TD></TD>\n</TR>\n" if $odd and $cnt == $tot;
    print "\n</TR>\n" if $col == 2;}


    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

    Comment

    • Laurey

      #3
      Re: Array information into 2 cells instead of 1?

      On Fri, 30 Jan 2004 01:27:30 GMT, Gunnar Hjalmarsson
      <noreply@gunnar .cc> wrote:

      *snip*[color=blue]
      >
      >Simply use a couple of extra check variables. Suggested additions and
      >changes below is an example.[/color]
      *snip*

      BEAUTIFUL!

      worked perfectly, thank you Gunnar! you have become my hero for the
      month!
      -L

      Comment

      Working...