Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Array information into 2 cells instead of 1?

Reply
Thread Tools

Array information into 2 cells instead of 1?

 
 
Laurey
Guest
Posts: n/a
 
      01-30-2004
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
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-30-2004
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

 
Reply With Quote
 
 
 
 
Laurey
Guest
Posts: n/a
 
      01-30-2004
On Fri, 30 Jan 2004 01:27:30 GMT, Gunnar Hjalmarsson
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert yyyymmdd text cells into date cells =?Utf-8?B?ZF9jYW1wZWxvQGhvdG1haWwuY29t?= Microsoft Certification 2 11-22-2006 04:52 PM
Writing to Cells in the Detailsview Insertmode makes cells uneditable. SixStringSlaya@gmail.com ASP .Net 0 02-28-2006 10:23 PM
Deleting cells by name instead of index? Rich Morey Javascript 6 06-08-2004 02:50 AM
Deleting cells by name instead of index? Rich Morey HTML 0 06-05-2004 04:43 PM
Cells[].Text or Cells[].Controls[0] Joel Finkel ASP .Net Datagrid Control 0 09-01-2003 04:42 PM



Advertisments