Program to show the table of a number in PHP

show table of a number in php

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 CodeExplanation
8if(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.

 

By:Prof. Fazal Rehman Shamil
CEO @ T4Tutorials
Last Modified: May 27, 2019

9 thoughts on “Program to show the table of a number in PHP

  1. this program is about print the table of num nd i enter k num nd gave me table of that num .

  2. I wrote this table PHP program.it gives the correct output. I enter 8 number in the input field I get the full table of 8

  3. I wrote this table PHP program.it gives the correct output. by just putting any number it generates the table of that number

Leave a Reply

Your email address will not be published. Required fields are marked *