-2
我想建立一个表,每个条目都有一个删除按钮,但输出令我困惑。代码如下:PHP生成混淆输出
if ($players != null) {
echo('<table class="playerTable">');
echo('<thead>');
echo('<tr>');
echo('<th> Last Name </th>');
echo('<th> First Name </th>');
echo('<th></th>');
echo('<th></th>');
echo('</tr></thead><tbody>');
for ($i=0; $i<count($players); $i++) {
printf('<form action="player.php" method="post" onSubmit="return submitCheck(\'%s\', \'%s\')">', $players[$i]->name, $players[$i]->surname);
echo("<tr>");
printf("<td> %s </td><td> %s </td>", $players[$i]->surname, $players[$i]->name);
echo('<td><input type="hidden" name="delete" value="'. $players[$i]->id .'"></td>');
echo('<td><input type="submit" value="Delete"></td>');
echo("</tr>");
echo('</form');
}
echo('</tbody></table>');
}
出于某种原因,我不明白,产生的输出如下:
<tbody>
<form action="player.php" method="post" onsubmit="return submitCheck('someName', 'someName')"></form>
<tr>
<td> someName </td>
<td> someName </td>
<td><input type="hidden" name="delete" value="1"></td>
<td><input type="submit" value="Delete">
</td>
</tr>
这当然导致了一个事实,即submitCheck不会被执行 - 我在这里错过了什么?
好吧,你告诉我们如何输出应'not'样子,护理提它如何'should'? –
只是通过附加所有这些东西来形成一个字符串,并在最后回显它,然后它将起作用 – developerCK
当然,