用php创建乘法表

用php创建乘法表,php,Php,我尝试使用php创建乘法表,如下所示: <?php $cols = 10; $rows = 10; ?> 。。。很多html代码 <?php echo "<table border=\"1\">"; for ($r =0; $r < $rows; $r++){ echo('<tr>'); for ($c = 0; $c < $cols; $c++)

我尝试使用php创建乘法表,如下所示:

<?php

$cols = 10;
$rows = 10;
?>

。。。很多html代码

<?php

echo "<table border=\"1\">";

        for ($r =0; $r < $rows; $r++){

            echo('<tr>');

            for ($c = 0; $c < $cols; $c++)
                echo( '<td>' .$c*$r.'</td></tr>');

        }

        echo("</table>");

?>

我可能错过了什么,但不知道是什么

如有任何建议,将不胜感激,谢谢

标记移动到内部
的外部,用于
循环:

echo "<table border=\"1\">";

for ($r =0; $r < $rows; $r++){

    echo('<tr>');

    for ($c = 0; $c < $cols; $c++)
        echo( '<td>' .$c*$r.'</td>');

    echo('</tr>');

}

echo("</table>");
echo”“;
对于($r=0;$r<$rows;$r++){
回声(“”);
对于($c=0;$c<$cols;$c++)
回声(“.$c*$r.”);
回声(“”);
}
回声(“”);
试试这个:

您正在关闭每个列的tr标记。 您需要在cloumn for循环之后关闭tr标记

echo "<table border=\"1\">";

        for ($r =0; $r < $rows; $r++){

            echo'<tr>';

            for ($c = 0; $c < $cols; $c++)
                echo '<td>' .$c*$r.'</td>';
           echo '</tr>'; // close tr tag here

        }

  echo"</table>";
echo”“;
对于($r=0;$r<$rows;$r++){
回声';
对于($c=0;$c<$cols;$c++)
回显“.$c*$r.”;
echo“”;//在此处关闭tr标记
}
回声“;

零件每行只能回显一次。此问题是由一个简单的印刷错误引起的。虽然这里可能有类似的问题,但这个问题的解决方式不太可能对未来的读者有所帮助。你的意思是什么?我该怎么编辑这篇文章呢?谢谢你,普林西奥夫!:)谢谢你,小伙子,这就是我所需要的