To customize this you're going to need to learn the basics of PHP. The directions above are enough once you do a few intro tutorials.
Here's an example of applying the class "bright" to every other row and the class "dark" to every other td-- this will create a checkered pattern. Do with it what you'd like. Adjust things as needed, but to get much control you'll need to customize it a bit.
PHP Code:
<?php
echo "<html>\n<body>\n\t<table style=''>\n\n";
$f = fopen("THECSVFILE.csv", "r");
$trcount = 0; //start the row count as 0
while (($line = fgetcsv($f)) !== false) {
$trclass = ''; if ($trcount%2==0) { $trclass=' class="dark"'; } //default to nothing, but if it's even apply a class
echo "\t\t<tr".$trclass.">\n"; //same as before, but now this also has the variable $class to setup a class if needed
$tdcount = 0; //reset to 0 for each inner loop
foreach ($line as $cell) {
$tdclass = ''; if ($tdcount%2==0) { $tdclass=' class="dark"'; } //default to nothing, but if it's even apply a class
echo "\t\t\t<td ".$tdclass."style='padding:.4em;'>" . htmlspecialchars($cell) . "</td>"; //same as before, but now this also has the variable $class to setup a class if needed
$tdcount++; //go up one each loop
}
echo "\r</tr>\n";
$trcount++; //go up one each loop
}
fclose($f);
echo "\n\t</table>\n</body>\n</html>";
?>
Obviously you'll want to define "light" and "dark" classes in your CSS and probably make it something like just a light row is very light; just a dark cell is very dark; a light row and dark cell is somewhere in the middle; neither dark cell nor light row is nothing; this is to be figured out in the css.
Basically you can do this in a number of ways and that's just an example. It'll work, though, if you like that method.
Another way would be to use a single variable for every cell and not apply any styling to the <tr>s. Just apply "dark" to every other cell (offsetting every other row by one).
Bookmarks