Array information into 2 cells instead of 1?

Discussion in 'Perl' started by Laurey, Jan 30, 2004.

  1. Laurey

    Laurey Guest

    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,$other) = 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
    Laurey, Jan 30, 2004
    #1
    1. Advertising

  2. Laurey wrote:
    > 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?


    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;

    > foreach $i (@indata)


    <snip>

    > $add2 = "</SPAN>";}



    $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
    Gunnar Hjalmarsson, Jan 30, 2004
    #2
    1. Advertising

  3. Laurey

    Laurey Guest

    On Fri, 30 Jan 2004 01:27:30 GMT, Gunnar Hjalmarsson
    <> wrote:

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

    *snip*

    BEAUTIFUL!

    worked perfectly, thank you Gunnar! you have become my hero for the
    month!
    -L
    Laurey, Jan 30, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    524
  2. Rich Morey
    Replies:
    0
    Views:
    321
    Rich Morey
    Jun 5, 2004
  3. Joel Finkel

    Cells[].Text or Cells[].Controls[0]

    Joel Finkel, Sep 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    306
    Joel Finkel
    Sep 1, 2003
  4. Rich Morey

    Deleting cells by name instead of index?

    Rich Morey, Jun 5, 2004, in forum: Javascript
    Replies:
    6
    Views:
    173
    Rich Morey
    Jun 8, 2004
  5. cerr
    Replies:
    1
    Views:
    126
    Piet van Oostrum
    Aug 16, 2013
Loading...

Share This Page