Reputation: 331
In one of my project I want to have pattern of certain number as depicted in image but its little chnaged, Any help will be appreciated
<?php
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++) {
echo "<tr> \n";
for ($col=1; $col <= 10; $col++) {
$p = $col+1 * $row+1;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
Expected Output
Upvotes: 0
Views: 1019
Reputation: 1
The Same code you use but you seen who you putted ($p = $col+1 * $row+1), u just gotta take the "+1" out in both, take care :)
<?php
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++) {
echo "<tr> \n";
for ($col=1; $col <= 10; $col++) {
$p = $col * $row;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
Upvotes: 0
Reputation: 1
enter code here<?php
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++) {
echo "<tr> \n";
for ($col=1; $col <= 10; $col++) {
$p = $col+1 * $row+1;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
Upvotes: 0
Reputation: 11
<?php
echo"Ashutosh Verma Branch_IT_9889313834";
echo"<br />";
echo "-------The table of 5-------";
echo"<br/>";
$s=5;
for($i=1; $i<=10; $i++)
{
$t = $i*$s;
echo $s."*".$i."=".$t."<br/>";
}
?>
------------Output Section-------
Ashutosh Verma Branch_IT_9889313834
-------The table of 5-------
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25
5*6=30
5*7=35
5*8=40
5*9=45
5*10=50
Upvotes: 0
Reputation: 2195
Try this:
<?php
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++) {
echo "<tr> \n";
for ($col = 1; $col <= 10; $col++) {
echo "<td>" . $col * $row . "</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
Upvotes: 1
Reputation: 3091
try this, remove increment in your $col and $row
echo "<table border ='1' style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++) {
echo "<tr> \n";
for ($col=1; $col <= 10; $col++) {
$p = $col * $row;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
i hope it will be helpful.
Upvotes: 1
Reputation: 439
Try this code...
<?php
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++)
{
echo "<tr> \n";
for ($col=1; $col <= 10; $col++)
{
$p = $col * $row;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
Upvotes: 0
Reputation: 1581
echo "<table>";
for ($i = 1; $i <= 10; $i++) {
echo "<tr>";
$temp = $i;
for ($m = 1; $m <= 10; $m++) {
echo "<td>" . $temp . "</td>";
$temp += $i;
}
echo "<tr>";
}
echo "</table>";
Upvotes: 1