Since you tried... here ya go

Code:

$i = 0;

print "<table BORDER=2>\n";

for (0 .. ($numhits - 1)) {

# LOGIC: If divide last $i by 4 and no remainder, create new row - e.g. $i = 0, 4 (actually the FIFTH record since starting with 0), 8, etc...

if ($i%4 == 0) { print "<tr>"; }

# LOGIC: Put each record in its own cell

print "<td>";

&html_record (&array_to_hash($_, @hits));

print "</td>";

++$i;

# LOGIC: If divide last $i by 4 and no remainder, end row - e.g. $i = 4 (we just incremented $i so can never be 0), 8, etc...

if ($i%4 == 0) { print "</tr>\n"; }

}

# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 1 => create 3 (4-1) blank cells

if ($i%4 ==1) { print "<td COLSPAN=3></td></tr>\n"; }

# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 2 => create 2 (4-2) blank cells

elsif ($i%4 ==2) { print "<td COLSPAN=2></td></tr>\n"; }

# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 3 => create 1 (4-3) blank cell

elsif ($i%4 ==3) { print "<td></td></tr>\n"; }

print "</table>";

With this code and comments, hopefully anybody can adapt it to tables of N columns...

------------------

The Immuatable Order of Modding

-=-=-=-=-=-=-=-

1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

[This message has been edited by oldmoney (edited February 26, 2000).]