Forum Moderators: coopster
Here's the structure of my HTML table...
<table>
<tr>
<td>x1 <br /> x2 <br /> x3 <br /> x4</td>
<td>x5 <br /> x6 <br /> x7 <br /> x8</td>
<td>blah blah blah</td>
</tr>
</table>
Any suggestions are welcomed.
$item_per_row = 3;
$content = '<tr>';
$sql = "SELECT * FROM table";
$rows = mysql_query($sql);
if (mysql_num_rows($rows) == 0) {
$content = '<td>No Items</td></tr>';
} else {
$count = 0;
while ($row = mysql_fetch_assoc($rows)) {
$content .= '<td>' . $row['item'] . '</td>';
if (++$count % $item_per_row === 0) $content .= '</tr>';
}
if ($count % $item_per_row !== 0) $content .= '</tr>';
}