<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Enter Number:<input type="text" name="Number" />
<input type="submit" value="Show Time table"/>
</form>
</body>
</html>
<?php
$numbers=range(1,12);
$Number = $_POST['Number'];
if ($Number < 1 or $Number > 12) {
// insert code to display an error
}
else {
foreach($numbers as $times) {
echo '<tr>';
$output = $Number * $times;
echo "<tr style='text-align: center'>$Number x $times = $output
</tr>";
echo '</tr>';
echo '</tr>';
}
}
?> This should do it. A form also needs an action. As you can see, there is no need to test for numeric input. If you enter anything else no output is generated.