PHP垂直字母表使用FOR循环


PHP Vertical Alphabet Using FOR Cycle

我正在尝试用PHP编写一个脚本,该脚本将生成一个包含垂直字母的表。它将简单地从a到Z回显字母,当它到达Z时,它将重置并重新从a开始。我有一个问题,因为我只能重复两次,然后所有的细胞都有一些不想要的迹象。我用他们的ASCII html代码回显字母,其中A符号是&65,并且Z符号是&90.

这是我到现在为止的代码,谢谢你的帮助。

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>Vertical alphabet</title>
</head>
<body>
    <form method="post">
        <input type="number" placeholder="COLUMNS" name="cols" />
        <input type="number" placeholder="ROWS" name="rows" />
        <input type="submit" value="Create table" /><br><br>
    </form>
        <?php
            if(isset($_POST['rows']) && isset($_POST['cols'])) {
                $col = $_POST['cols'];
                $row = $_POST['rows'];
                echo ("<table rules='all'>");
                for($i = 1; $i<$row+1; $i++) {
                    echo ("<tr>");
                    for($c = 0; $c<$col; $c++) {
                        $letter_id = 65;
                        $number = ($i + ($c*$row)-1);
                        $letter = $number + $letter_id;
                        if($letter > 90) {
                            $number = $number - 26;
                            $letter = $letter - 26;
                            echo ("<td>". "&#" . $letter. "</td>");
                        } else {
                            echo ("<td>". "&#" . $letter. "</td>");
                        }
                    }
                    echo ("</tr>");
                }
                echo ("</table>");
            }
        ?>
</body>
</html>

不确定您试图用$number变量做什么,但这就是的问题

$number = 0;
echo ("<table rules='all'>");
for($i = 1; $i<=$row; $i++) {
     echo ("<tr>");
     for($c = 0; $c<$col; $c++) {
          $letter_id = 65;
          $number = $i + ($c*$row);
          $letter = $number + $letter_id;
          while($letter > 90) {
                $letter = $letter - 26;
          }
          echo ("<td>". "&#" . $letter. "</td>");
     }
     echo ("</tr>");
}
echo ("</table>");

更新:

现在垂直,试试这个。。。

因为$number总是长大的
第一个A-Z,$数字在0到25之间,如果是其他情况,则可以。
第二个A-Z,$数字在26和51之间,如果你在if情况下,你去掉26,你的打印就可以了。

下一个$数字是52,如前所述,您使用if大小写并尝试打印字母表^^的第27个字母