Can someone assist with this code? What I want to do is build a table by looping through data. The table should be four cells across, then end with a </tr> tag, switch background color for another four cells, etc., to the end of the data. The code below iterates four proper cells, spits out a </table>, then four lines w/o table information (it is counting correctly), then another proper four cells, etc.. Maybe I'm tired....
<?php
$tdcount = 1;
$numtd = 4;
$numrow =5;
echo "<table width=100%>";
for($i=0;$i<$numrow;$i++){
//define which colors for even and odd line numbers
if($i % 2 == 0) {
$bgcolor='#f3f3f3';
} else {
$bgcolor='#e3e3e3';
}
if ($tdcount == 1) echo "<tr bgcolor=$bgcolor>";
echo "<td>[data]</td>";
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td>[data]</td>";
$tdcount++;
}
echo "</tr>";
}
echo "</table>";
}
?>