0

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>";  
?>  

enter image description here

Expected Output

enter image description here

1

7 Answers 7

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1
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>";

Comments

1

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>";  
?>

Comments

0

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>";  
    ?> 

2 Comments

can you explain why $row*1?
I think no need to do that. we should remove it.
0
<?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

1 Comment

It would be helpful to explain at least a bit how your code works, and not just post plain code.
0
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>";  

?>

1 Comment

use script for moor and moor updates in your web pages
0

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>";  
?>  

2 Comments

Escape character =\"1\" for what?
when you take =\"1\" the output will not start with 3, it will start with 1, and the this : ($p = $col * $row;) will work, making it look like the "Expected Output" that he asked for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.