PDA

View Full Version : Listing query results in columns


DjSap
27 Feb 2002, 13:23
Well im working on a classifieds hack for my board and i want to display all the categories evenly divided in a table with 3 columns and 1 row, only thing im able to do right now is display the results in rows. I havent been able to find a tutorial or something about this so could someone help me out on this?

Chen
27 Feb 2002, 14:58
In general:
<?php

$result = $DB_site->query("SELECT * FROM tblName");
$cellcounter = 0;

while ($row = $DB_site->fetch_array($result) and ++$cellcounter) {
if ($cellcounter%3 == 0) {
echo "<tr>\n";
}
echo "<td>" . $data . "</td>\n";
if ($cellcounter%3 == 0) {
echo "</tr>\n";
}
}

?>