Skip to content

PHP Programs 5

Print multiplication table of a number input by the user.

<html>
<head>
<title>p5</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter the number"/>
</td>
</tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$num = $_POST['num1'];
echo "the multiplicatin table of  $num is as follow :</br>";     
  for ($i = 1; $i <= 10; $i++) {
    echo  $num, " x ", $i, " = ", $num * $i, "<br>";
  }
}
?>
</body>
</html>

Output