Jump to content

php multiplication tables


mayman212

Recommended Posts

<?php      

echo "<tableborder=1>";
echo "<table> \n";                    
echo "    <tr>\n"; 

$a= 1;
$b= 1;

while ($a <= 9 && $b <= 10){
$calc = $a * $b;


echo "        <td>$calc</td>\n";

        $a++;

if ($a == 9){

echo "   </tr>\n";

    if ($b < 10)

echo "   </tr>\n";

 $a = 1;

 $b++;
}
}


echo "</table>";
?>

 

I am trying to do the multiplication tables but so far i can only manage to get this.

it only shows the answers but i want it to show the tables along with the calculation, so for example:

1*2=2

2*2=4 etc.

I want it to show on a repeating loop so it runs up to the 9 times tables.

Any help on this?

Link to comment
https://forums.phpfreaks.com/topic/250229-php-multiplication-tables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.