Generating tables of numbers in PHP I have this code and this works fine but I think it's too lengthy. I want to know if there can be a less lengthy code. I've heard from people that lengthy code is often not considered good.

&lt;html&gt;
&lt;head&gt;&lt;title&gt;Table&lt;/title&gt;&lt;/head&gt; 
&lt;body&gt;
&lt;form method = "Post" action = "Table.php" &gt; 
Enter a number between 2 and 20 to see its tables: 
&lt;input type = "text" name = "number" /&gt; 
&lt;input type = "hidden" value = "true" name = "checker" /&gt; 
&lt;/form&gt; 
&lt;?PHP 
if ( isset($_POST['checker'])) { 
$number = $_POST['number']; 
switch ($number) { 
case 2: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 3: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 4: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 5: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 6: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 7: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 8: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 9: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
case 10: 
for ( $counter = 1 ; $counter &lt;= 10 ; $counter++ ) {
$temp = $number * $counter ; 
echo "$number x $counter = $temp&lt;br /&gt;"; 
} 
break;
default:
echo "Please enter a number between 2 and 10"; 
} 
} 
?&gt; 
&lt;/body&gt;
&lt;/html&gt;
Already gave in the wrong placed question, anyway here is my solution: codepad.viper-7.com/zTLliA
Copy&amp;paste is never a good idea.
if (isset($_POST['number']) &amp;&amp; is_numeric($_POST['number']) &amp;&amp; (($_POST['number'] &gt; 0) &amp;&amp; ($_POST['number'] &lt;= 20))) { 
    $number = $_POST['number'];
    for ( $counter = 1 ; $counter &lt;=10; $counter++ ) {
        $temp = $number * $counter ;
        echo &quot;$number x $counter = $temp&lt;br /&gt;&quot;; 
    }
} else {
    echo &quot;Please enter a number between 1 and 20&quot;; 
}

A single for is enough. In the if statement we check if the $_POST['number'] exists, if it's actually a number and if it is between 1 and 20.