What you need to do is something like this:
<?php
$rows = 10;
$cols = 4;
echo "<table border='1'>";
for($tr=1;$tr<=$rows;$tr++){
echo "<tr>";
for($td=1;$td<=$cols;$td++){
echo "<td>row: ".$tr." column: ".$td."</td>";
}
echo "</tr>";
}
echo "</table>";
?>
To receive the number of columns from a form use either the POST or GET methods.
Please refer to this tutorial:
http://www.w3schools.com/php/php_get.asp[
^]