【发布时间】:2017-06-25 14:54:19
【问题描述】:
在我的第一段代码中,您可以看到我如何使用回显输出构建表格。一切正常。
echo "<form method=\"post\" action=''>";
echo "<table border=\"1\">";
foreach($pdo -> query($sqlSpielerNamen) as $row){
echo "<tr>";
echo "<td style=\"font-size: 10;\">".$row['Player_ID']."</td>";
echo "<td style=\"font-size: 10;\">".$row['SpielerName']."</td>";
echo "<td syle=\"font-size: 10 ;\"><input name='note' type='text' class='textfield' id='note_id' value='$spielID' />";
echo "<td syle=\"font-size: 10 ;\"><input name='tore' type='text' class='textfield' id='tore_id' value='$spielID' />";
echo "</tr>";
}
echo "</table>";
echo "<br><br><input type=\"submit\" name=\"submit_eingabemaske\" value=\"Abschicken\">\n";
echo "</form>";
但是现在,我需要在单击提交按钮后从此表中获得新的输出。 我需要第一个字段“Player_ID”和最后两个字段“note”和“tore”。
目前我的输出看起来像这样。但我知道这不是正确的解决方案。
if (isset($_POST['submit_eingabemaske'])){
$Po = $_POST["tore"];
foreach ($row as $item){
echo $Po;
}}
我必须在第二段代码中做些什么,我的结果才会正确。我怎样才能做到这一点?我的另一个问题是,如何调用第一个字段“Player_ID”?我可以使用 $POST["tore"] 获得的字段 'tore' 和 'name'...
【问题讨论】:
-
name='note'应该是name='note[]'并且对于其他输入也是如此,然后遍历该数组并输出。还要对所有 HTML 属性使用单引号。 ID 也应该是唯一的,如果值相同,您实际上不需要第二个输入,对吧?
标签: php html-table echo