This is pretty much a purely cosmetic thing. I have a few tables that are being populated via a SQL query. When the query returns an even result, the table is fine and looks something like this:
||||||
||||||
||||||
So that's not the problem. The problem occurs in the last row when there's a result that isn't perfectly divisible by four. I just get a blank space where I would like 1 to 3 "filler" TDs to be.
||||||
||||||
|_|X X X
So what I'm looking to do is append extra TDs that say "No data" when there is no data present for them. For whatever reason the math involved is going over my head, when in actuality I suspect it's rather simple. Any help or pointers would be awesome and very much appreciated. 🙂
Here's a snippet of my code so far:
while (!$rs->EOF) {
$data_id = $rs->fields["data_id"];
$catname = $rs->fields["catname"];
$per_row = 4;
$row_count = 0;
echo '
<table class="spacedtable">
<tr>
<th colspan="'.$per_row.'">'.$catname.'</th>
</tr>
<tr>';
do {
$data_id = $rs->fields["data_id"];
$data_name = $rs->fields["data_name"];
if ($row_count == $per_row) {
echo "</tr><tr>";
$row_count = 0;
}
echo '<td class="box" width="25%">'.$data_name.'</td>';
$row_count++;
$rs->MoveNext();
}
while($data_id == $rs->fields["data_id"]);
echo '</tr></table><br />';
}