I have a table that collects data from web inputs and stores them on an html page... the question how do i style this table... I am not sure how to give it borders, style columns (column 1 is red, 2 is blue, 3 is red, so on), or color the headers... i think i am just lost in my code, but can someone help me?
My code:
<?php
echo "<html>\n<body>\n\t<table style=''>\n\n";
$f = fopen("MYCSVFILE.csv", "r"); //Safe
$trcount = 0; //start the row count as 0 //start from the column heading
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>";
?>