PHP Tutorial : Generate multiplication table from any number to any number

3

Generate multiplication table from any number to any number in PHP

We are going to learn PHP code to generate tables from any number to any number up to 10 multiplies.

This tutorial consist of 3 parts : HTML / CSS / PHP

HTML is to display the tables and CSS is to decorate those table. Main part is of PHP which will generate tables from any number to any.

So lets start.

Here in this tutorial to display better output i used Bootstrap so that all tables will come in Col-Sections

<?php
echo '<div class="row container">';

$number1 = 2;
$number2 = 20;

$difference = $number2 - $number1;

for($i=0;$i<=$difference;$i++)
{
    $ar = $number1+$i;
    echo '<div class="col-sm-3 text-center"><div class="box">';
    echo '<div class="box-head">Table Of '.$ar.'</div>';

    for($k=1;$k<=10;$k++)
    {
        echo $ar.'x'.$k.' = '.$ar*$k.'<br />';	
    }

    echo '</div></div>';
}

echo '</div>';
?>

 

Above code will generate tables from 2 to 20 , Table of 2 , 3, 4 …… so on upto 20. And this will display like this given below

php tutorial generate tables

Hope this will help some of our reader.

Have a nice day.

 

Do you love PHP codes ? If you are here are some more interesting tutorials

How geotarget location works in PHP

How to get real IP address of Visitor ?

3 thoughts on “PHP Tutorial : Generate multiplication table from any number to any number

  1. I just like the helpful information you supply from your articles.
    I’ll bookmark your weblog and check once more right here frequently.

    Good luck for the following!

Leave a Reply

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

10  ⁄    =  2