Array information into 2 cells instead of 1?

L

Laurey

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
 
G

Gunnar Hjalmarsson

Laurey said:
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)

$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;}
 
L

Laurey

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

*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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top