Changing CSS class through PHP
Its a very simple way of changing css class using php, all you have to do is to run a for loop and each loop it will change the class.

First we define css classes as gray blue green and black, and we’ll use it in table using php.
<html>
<title>Changing CSS class through PHP - Demo</title>
<head>
<style>.gray{background-color:red; color:white;font-size:20px; font-weight:bold; }
.blue{background-color:blue; color:white;font-size:20px; font-weight:bold; }
.green{background-color:green; color:white;font-size:20px; font-weight:bold; }
.black{background-color:black; color:white;font-size:20px; font-weight:bold; }
</style>
</head>
<body><table width=”500″ border=”6″ cellspacing=”6″ cellpadding=”6″ >
<?php
for($row=1; $row<=10; $row++)
{ echo “<tr>”;
for($column=1; $column<=4; $column++)
{
switch($column){
case 1: $class=”gray”; break;
case 2: $class=”blue”; break;
case 3: $class=”green”; break;
default: $class=”black”;
}
echo “<td class=\”$class\” align=\”center\”>[$row,$column]</td>”;
}echo “</tr>”;
}
?>
</table>
</body>

