Program to show the table of a number in PHP

By: Prof. Fazal Rehman Shamil
Last modified on October 14th, 2020

Program to show a table of a number till 10

In this tutorial, we will learn that how to print the table of a number and number will be input by the user.

For this purpose, we need to make two text boxes in a form and then assign names to each of the form element. For example, here we assign the following names.

  • Input type text is named as “value”.
  • Input type submit is names as “btn“.

Now we can put the values of form elements “value” and “btn” in some variable by POST method and further necessary actions will be carried out.

Output.

show table of a number in php
Figure: table of a number in php.
Line No Code Explanation
8 if(isset($_POST[‘btn’])) It will check that values are successfuly POSTED from form or not.
10 $n=$_POST[‘value’]; Right side takes the values from the form element (named as “value”) and this value is the value which is posted by user with the help of form.

Now we can put the value of right side into left side into the variable $n.

Program to show a table of a number till 20.

In this example, we will take the inputs from the user and store them in variables.

Prof. Fazal Rehman Shamil
Latest posts by Prof. Fazal Rehman Shamil (see all)