Hello
Just wrote a few Random PHP Programs creating Numbers Table 1 to 100. Remember in Nursery our Teachers made us write these numbers so many times in our Maths Notebook.
So Here comes a quick way to print the Numbers in Nice Colorful Tables.
Table_1.php
<html>
<head>
<title>Number Table using PHP</title>
<style type="text/css">
td
{
height:50px; width:50px;
}
table,th,td
{
font-family:Arial; font-size:17px;
color:navy; font-weight: normal;
border: 2px solid red;
text-align: center;
border-collapse:collapse;
}
th
{
font-family:Arial; font-size:25px;
color:white; font-weight: bold; font-style:italic;
text-align: center;
}
</style>
</head>
<body>
<?php
echo "<table border=\"1\" align=\"center\" bgcolor=\"red\">";
echo "<tr> <th colspan=\"10\"> Number Table </th> </tr>";
//For loop will iterate for 10 times to create 10 rows.
for($i=1;$i<=10;$i++)
{
echo "<tr align=\"center\">";
for($j=9;$j>=0;$j--)
{
echo "<td bgcolor=\"white\">";
$t=10*($i);
$t1=$t-$j;
echo $t1;
echo "</td>";
}//for loop ends
echo "</tr>";
}//outer for end.
echo "</table>";
?>
</body>
</html>
Snapshot of the o/p

Number Table 1 to 100
Table_2.php
<html>
<head>
<title>Number Table using PHP</title>
<style type="text/css">
td
{
height:50px; width:50px;
}
table,th,td
{
font-family:Arial; font-size:17px;
color:navy; font-weight: normal;
border: 2px solid red;
text-align: center;
border-collapse:collapse;
}
th
{
font-family:Arial; font-size:25px;
color:WHITE; font-weight: bold; font-style:italic;
text-align: center;
}
</style>
</head>
<body>
<?php
echo "<table border=\"1\" align=\"center\" bgcolor=\"red\">";
echo "<tr> <th colspan=\"10\"> Number Table </th> </tr>";
//For loop will iterate for 5 times to create 10 rows.
for($i=1;$i<=10;$i=$i+2)
{
echo "<tr align=\"center\">";
for($j=9;$j>=0;$j--)
{
echo "<td bgcolor=\"white\">";
$t=10*($i);
$t1=$t-$j;
echo $t1;
echo "</td>";
}//for loop ends
echo "</tr>";
echo "<tr align=\"center\">";
for($j=1;$j<=10;$j++)
{
echo "<td bgcolor=\"pink\">";
$t=10*($i);
$t1=$t+$j;
echo $t1;
echo "</td>";
}//for loop ends
echo "</tr>";
}//outer for end.
echo "</table>";
?>
</body>
</html>
Snapshot of the o/p

Number Table 1 to 100 with Different colored rows
Table_3.php
<html>
<head>
<title>Number Table using PHP</title>
<style type="text/css">
td
{
height:50px; width:50px;
}
table,th,td
{
font-family:Arial; font-size:17px;
color:navy; font-weight: normal;
border: 2px solid red;
text-align: center;
border-collapse:collapse;
}
th
{
font-family:Arial; font-size:25px;
color:WHITE; font-weight: bold; font-style:italic;
text-align: center;
}
</style>
</head>
<body>
<?php
echo "<table border=\"1\" align=\"center\" bgcolor=\"red\">";
echo "<tr> <th colspan=\"10\"> Number Table </th> </tr>";
//For loop will iterate for 5 times to create 10 rows.
for($i=1;$i<=10;$i=$i+2)
{
echo "<tr align=\"center\">";
for($j=9;$j>=0;$j--)
{
if(($j%2)==0)
{
echo "<td bgcolor=\"white\">";
}
else
{
echo "<td bgcolor=\"pink\">";
}
$t=10*($i);
$t1=$t-$j;
echo $t1;
echo "</td>";
}//for loop ends
echo "</tr>";
echo "<tr align=\"center\">";
for($j=1;$j<=10;$j++)
{
if(($j%2)==0)
{
echo "<td bgcolor=\"pink\">";
}
else
{
echo "<td bgcolor=\"white\">";
}
$t=10*($i);
$t1=$t+$j;
echo $t1;
echo "</td>";
}//for loop ends
echo "</tr>";
}//outer for end.
echo "</table>";
?>
</body>
</html>
Snapshot of the o/p

Number Table 1 to 100 with different cell colors
Table_4.php
<html>
<head>
<title>Number Table using PHP</title>
<style type="text/css">
td
{
height:50px; width:50px;
}
table,th,td
{
font-family:Arial; font-size:17px;
color:navy; font-weight: normal;
border: 2px solid red;
text-align: center;
border-collapse:collapse;
}
th
{
font-family:Arial; font-size:25px;
color:WHITE; font-weight: bold; font-style:italic;
text-align: center;
}
</style>
</head>
<body>
<?php
echo "<table border=\"1\" align=\"center\" bgcolor=\"red\">";
echo "<tr> <th colspan=\"10\"> Number Table </th> </tr>";
for($i=10;$i>=1;$i--)
{
echo "<tr align=\"center\">";
//For loop creates rows of numbers in Descending order..100,99,98,...,91
for($j=0;$j<10;$j++)
{
//For different color cells we have used if condition
if(($j%2)==0)
{
echo "<td bgcolor=\"white\">";
}
else
{
echo "<td bgcolor=\"pink\">";
}
$t=10*($i);
$t1=$t-$j;
echo $t1;
echo "</td>";
}
//for loop ends
echo "</tr>";
}//outer for end.
echo "</table>";
?>
</body>
</html>
Snapshot of the o/p

Number Table 1 to 100 in Descending Order



