【发布时间】:2021-09-20 15:24:02
【问题描述】:
我的任务是让文本输入发送多达 16 个变量以垂直打印在下方,名称本身彼此水平排列。我正在使用一个表格来执行此操作(将每个字母打印在一行上),并将这些表格放在一个更大表格的一行中的单元格中,以便它们水平组织。
此代码成功打印了一个输入,但它只处理一个输入。我已经将它设置为打印更多,我只需要更多输入。我应该只使用一个输入来完成所有操作。我不知道该怎么做。
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body><br><br>
<form action="question_2.php" method="post">
<input type="text" name="$N">
<button type="submit">Print</button>
</form>
<!-- a table for containing tables that are generated within cells in a single row -->
<table name="teams_table"><tr>
<?PHP
// insert it into each input and then to be grabbed via a GET request
$N = $_GET['$N'];
// start without any filled "team" cells
if ($N == null) {
return 0;
} else {
// verticalize each team name into a table and insert it into a table cell
$name = verticalise($N);
echo "<td><table name=team_table>" . $N . "</table></td>";
}
// turn each string into a table of rows of chars
function verticalise($N) {
$char = "";
for ($a = 0; $a < strlen($N); ++$a) {
$char .= "<tr><td>" . $N[$a] . "</td></tr>";
}
return $char;
}
?>
</tr></table>
</body>
</html>
示例输入/输出如下所示: ui
帮助非常感谢
【问题讨论】:
-
你能提供示例输入和输出吗?
-
尝试发送 16 个输入,然后用您尝试过的内容更新您的问题,什么不符合预期的输出
-
我会发布示例图片
-
尝试发送不止一个只是用一个打印的输入更新页面
-
我现在把那张图片和表格的代码包括进来