Infolinks

Breaking

Adsense

Friday, January 29, 2016

MULTIPLICATION TABLE: Display Multiplication Table using Loop in PHP

Hey guys! My new article is about displaying a multiplication table for the number 9. The $num contains 9 which will serve as our multiplicand and $i contains value that will serve as a multiplier. $i value starts with one (1) and will increment until 10. In short, 9 will be multiplied starting from 1 until 10 since the value of $i will increment by one (1) every time it enters the loop.

In the code below, I used the while loop but you can achieve it using for loop and even do while loop.

Try Multiplication Table in PHP here! Live!



PHP Code Multiplication Table

<?php
$num=9;
$i=1;
while ($i<=10)
{
$total=$num*$i;
echo $num." * ".$i." = ".$total."<br>";
$i++;
}
?>

Output Multiplication Table








Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

MULTIPLICATION TABLE: Display Multiplication Table using Loop in PHP

No comments:

Post a Comment

Adbox