print matrix and color diagonally
$no=9;
echo "<center>";
echo "<table>";
for ($row=1; $row<=8 ; $row++) {
$no--; //to decrement
echo "<tr>";
for ($col=1; $col<=8; $col++) {
$color="";
if ($row==$col) {
$color = 'background-color:red';
}
if ($col==$no) { //col val == 8
$color = 'background-color:green';
}
echo "<td style=".$color.">".$row*$col."</td>";
}
echo "</tr>";
}
echo "</table>";
echo "</center>";