
How can i make this background myself using css and php?

|
|
|
$colors = array("#E9F0FF", "#FFFFFF");
Then theres a loop for the rows: for ($i = 0; $i < 21; $i ++) { /*20 rows*/
$color = $colors[$colorCount];
echo "<tr bgcolor='$color'>
<td>Value</td>
<td>More value</td>
</tr>";
$colorCount++;
}
Now, in the loop which spawns the rows, i made a little statement which tells them when to reset the value to 0. if ($colorCount > count($colors) - 1) {
$colorCount = 0;
}
And it works so yay!
<?php
print "<TABLE BORDER=\"1\">\n";
print "<TR bgcolor=\"lightblue\"><TD>Foo</TD><TD>Two</TD><TD>Thre</TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
print "<TR bgcolor=\"lightblue\">\n";
} else { //if there isn't a remainder we will do the else
print "<TR bgcolor=\"white\">\n";
}
print "<TD>".$row['foo']."</TD><TD>".$row['two']."</TD><TD>".$row['three']."</TD>\n";
print "</TR>\n";
}