<html>
<body>
<h1>Multiplication Tables</h1>
<?php
mult(10, 10);
$maxRow = rand(1,10);
$maxCol = rand(1,10);
mult($maxRow, $maxCol);
//------------------------------------------------------------
function mult($maxRow, $maxCol)
{
print "<h2>$maxRow x $maxCol </h2> \n";
print "<table border=1> \n";
print "<tr bgcolor=cyan>";
print "<th width='25'> X </th>";
for ($colHead =1; $colHead <= $maxCol; $colHead++) //loop for as many times as $maxCol
print "<th width=25>" . $colHead . "</th>"; //print column headers
print "</tr> \n";
for ($row =1; $row <= $maxRow; $row++)
{
print "<tr>";
print "<th bgcolor=cyan> $row </th>"; //print row header
$col = 1;
while ($col <= $maxCol)
{
print "<td align=right>" . $row*$col . "</td>"; //print row * col
$col++;
}
print "</tr> \n";
}
print "</table> <br>\n";
}
//------------------------------------------------------------
?>
<?php include "../include.php"; ?> <!-- hyperlink to see the code -->
</body>
</html>