function drawTable cols rows color echo table for rows echo tr for col

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
function drawTable($cols, $rows, $color){
echo '<table>';
for ($i=1; $i < $rows; $i++) {
echo '<tr>';
for ($j=1; $j < $cols; $j++) {
if($i == 1) {
echo '<td style="text-align:center; background:red;"><b>'. $i * $j .'</b></td>';
continue;
}
if($j == 1) {
echo '<td style="text-align:center; background:red;"><b>'. $i * $j .'</b></td>';
continue;
}
echo '<td style="background:'.$color.';">'. $i * $j .'</td>';
}
echo '</tr>';
}
echo '</table>';
}