52. PHP Program to Display the Multiplication table for a given number.
How does this program work?
- In this program we are going to learn about how to display multiplication table for given number using PHP.
Here is the code
<html>
<head>
<title>PHP Program To display Multiplication table</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter table number"/> </td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter starting number of table"/> </td>
</tr>
<tr>
<td> <input type="text" name="num3" value="" placeholder="Enter ending number of table"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$t = $_POST['num1'];
$s = $_POST['num2'];
$e = $_POST['num3'];
for($i = $s; $i <= $e; $i++)
{ echo ("$t * $i = ".$t * $i )." "; }
return 0;
}
?>
</body>
</html>