Monthly Archives: November 2012

for loops to create a multiplication table for php

<?php
$start = 1;
$end = 10;

print ‘<table border=”1″ cellspacing=”0″ cellpadding=”5″>’;
for ($y = $start – 1; $y <= $end; ++$y) {
print “<tr>”;
for ($x = $start – 1; $x <= $end; ++$x) {
if ($y == $start – 1) {
print “<td><b>$x</b></td>”;

} else if ($x == $start – 1) {
print “<td><b>$y</b></td>”;
} else {
print “<td>”;
print $x*$y;
print “</td>”;
}
}
print “</tr>”;
}
print “</table>”;?>