Translate

Monday 23 September 2013

Multiplication Tables in PHP Coding

ScreenShot:
          

Display:

index.php:

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="400" border="1" cellspacing="0" cellpadding="5" id="tbl">
    <tr>
      <td width="144"><label for="start">Multiply From</label></td>
      <td width="330"><input type="text" name="start" id="start" /></td>
    </tr>
    <tr>
      <td><label for="end">Multiplt To</label></td>
      <td><input type="text" name="end" id="end" /></td>
    </tr>
    <tr>
      <td><label for="mult">Multiply By</label></td>
      <td><input type="text" name="mult" id="mult" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" id="submit" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>

PHP Coding:

<?PHP

$times = 2;

if (isset($_POST['submit'])) {

$start = $_POST['start'];
$end = $_POST['end'];
$times = $_POST['mult'];

for($start; $start <= $end; $start++) {

$answer = $start * $times;
print $start . " multiplied by " . $times . " = " . $answer . "<BR>";

}

}

?>

No comments:

Post a Comment