PHP
for($table=1; $table < 13; $table++){
echo "<table border='1' width='200'>";
echo "<tr><td>Table: ".$table."</td></tr>";
for($counter=1; $counter < 13; $counter++){
$answer=$table*$counter;
if($counter % 2 == 0){ //Modulus 2: Remainder of 0 (alternating rows of bold text)
echo "<tr><td><p><b>".$table." x ". $counter." = ".$answer."</b></p></td></tr>";
}
else{
echo "<tr><td><p>".$table." x ".$counter." = ".$answer."</td></tr></p>";
}
}
echo "</table>";
}
//Resullt
Table: 1 |
1 x 1 = 1
|
1 x 2 = 2
|
1 x 3 = 3
|
1 x 4 = 4
|
1 x 5 = 5
|
1 x 6 = 6
|
1 x 7 = 7
|
1 x 8 = 8
|
1 x 9 = 9
|
1 x 10 = 10
|
1 x 11 = 11
|
1 x 12 = 12
|
Table: 2 |
2 x 1 = 2
|
2 x 2 = 4
|
2 x 3 = 6
|
2 x 4 = 8
|
2 x 5 = 10
|
2 x 6 = 12
|
2 x 7 = 14
|
2 x 8 = 16
|
2 x 9 = 18
|
2 x 10 = 20
|
2 x 11 = 22
|
2 x 12 = 24
|
....etc. (up to Table 12)
No comments:
Post a Comment