in reply to Database Listing Question

You could build an array of HTML table cell fragments, and then iterate through 12 elements of the array. Each row will begin at index % 3 == 0, and end at index % 3 == 2.
# --- push everything into an array --- my @match = (); foreach my $line (@array) { if ($line =~ /\Q$search\E/i) { my ($category,$item_name,$item_price,$item_picture) = split /\|/, $line; push @match, <<End_of_line; <td valign=top CLASS=MENU1> <img src="$photo_loc/$photo1" width=75 height=75><BR> <B>$item_name</B><BR> $item_price<BR> </td> End_of_line } } # --- Print the table --- my $inrow; print "<table>\n"; for (0..11) { # want 12 images $cell = shift(@match) or last; $inrow++, print "<tr>" if ($_ % 3) == 0; print "$cell"; $inrow--, print "</tr>\n" if ($_ % 3) == 2; } print "</tr>\n" if $inrow; print "</table>\n";

Replies are listed 'Best First'.
Re: Re: Database Listing Question
by lisaw (Beadle) on Jan 22, 2004 at 01:51 UTC
    Hi Roger, That did the trick. Thank you so much! I sincerely appreciate your assistance. Lis