You used $y in both loops :)
<?php
echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\"> \n";
for ($x=1; $x<=12; $x++) {
echo "<tr> \n";
for ($y=1; $y<=12; $y++) {
echo "<td>";
echo ($x * $y);
echo "</td> \n";
}
echo "</tr> \n";
}
echo "</table>";
?>
Main Topics
Browse All Topics





by: dakydPosted on 2005-10-05 at 12:25:45ID: 15024826
You used the same varialbe twice ... both inner & outer loops were iterating through $y. I changed the outer one to use $x, hope that helps.
<?php
echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\"> \n";
for ($x=1; $x<=12; $x++) {
echo "<tr> \n";
for ($y=1; $y<=12; $y++) {
echo "<td>";
echo ($x * $y);
echo "</td> \n";
}
echo "</tr> \n";
}
echo "</table>";
?>