Print Table of a Number Using PHP Program, How to Display Table Number in PHP, PHP Program Print Table Number
PHP Code: Print table in php using for loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <?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 Table of a Number - Code4Example</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<=10;$i++){ ?> <tr> <td><?=$i?></td> <td>x</td> <td><?=$number?></td> <td>=</td> <td><?=$i*$number?></td> </tr> <?php } ?> </table> </body> </html> |
Output:

Write a PHP Program to Print Table of a Number