I really wish I was at home right now so I could test this out... I'll certainly give this a shot tonight. Taking someone else's earlier suggestion and tweaking it a bit, I was wondering if the following might work:
$cells = 10; //set desired number of cells per column $numRows = mysql_num_rows($result); //determine number of rows $numCols = ceil($numRows/$cells); //determine number of columns needed print "<center><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"; //start main table for($i=0; $i<$numCols; $i++) { echo "<tr><td align=\"center\">\n"; //setup main row/cell echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0 \">\n"; //setup secondary table while($dataArray = mysql_fetch_array($result)) { //print results of SQL in secondary table extract($dataArray); $n++; printf("<tr>\n<td align=\"center\" valign=\"center\"><a href=\"year.asp?year=%\">%s</td>\n</tr>", $grad_year, $grad_year); if ($n==$cols) { echo "</table>"\n; //close secondary table at 10 cells } echo "</td></tr>\n"; //close main row/cell } echo "</table>\n"; //close main table Jason Soza ----- Original Message ----- From: "Michael Davey" <[EMAIL PROTECTED]> Date: Thursday, July 11, 2002 12:01 pm Subject: [PHP] Re: Table Making > How about working out the length of the column (by dividing the > number of > rows by the number of cols you want), dump your results into an > array and > using the col length as an offset to pick through the resulting table? > > // $data is an array of results > > $rows = count ($data) > $row_len = round ($rows / 3); // three cols > > print "<table>"; > for ($i = 0; $i < $row_len; $i++) > { > print "<tr>"; > print "<td>".$data[$i]."</td>"; > print "<td>".($row_len + $i < $rows)?$data[$row_len + > $i]:" "."</td>"; > print "<td>".((2 * $row_len) + $i < $rows)?$data[(2 * > $row_len) + > $i]:" "."</td>"; > print "</tr>" > } > print "</table>"; > > This is off the cuff code and I think the row length's might need > some extra > checking, but sth like this should work... (crosses fingers) > > Mikey > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php