How to generate the multiplication table in php

Design a Simple web page to generate multiplication table for a given number

<?php

 $number=empty($_POST["number"])?1:$_POST["number"];

  ?>

 <!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Write a PHP Program to Print Multiplication Table of a Number </title>

</head>

<body>

    <form action="" method="post">

    <input type="text" name="number" value="<?=$number?>" placeholder="ex:3">

    <button type="submit">Calculate</button>

    </form>

    <?php echo $number ; ?>

    

    <table border="1" width="200">

    <?php  for($i=0;$i<=20;$i++){ ?>

        <tr>

            <td><?=$i?></td>

            <td>x</td>

            <td><?=$number?></td>

            <td>=</td>

            <td><?=$i*$number?></td>

        </tr>

    <?php  } ?>

    </table>

</body>

</html>

Comments

Popular posts from this blog

How to create Animated 3d chart with R.

Linux/Unix Commands frequently used

R Programming Introduction