我有表格:
<?php
while ($row = mysql_fetch_array($result)) {
echo "<form action='login.php' method='POST'>";
echo "<tr>";
echo "<td align='center' valign='middle'><input type='text' name='listid' value=" . $row['g_id'] . " readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='listid' value=" . $row['t1name'] . " readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='listid' value=" . $row['t2name'] . " readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type ='submit' value ='Confirm game'></td>";
echo "</form>";
echo "</tr>";
}
?>
除1个问题外,代码工作正常。
变量$ row ['t1name']和row ['t2name']各包含3个单词。但是,该字段的值仅被指定为第一个单词。在第一个空格之后没有任何内容。
如果我执行print_r($ row),我会得到:
Array
(
[0] => 1
[g_id] => 1
[1] => 2011-03-22
[date] => 2011-03-22
[2] => 1
[team1] => 1
[3] => John Doe A
[t1name] => John Doe A
[4] => 9
[t1pnts] => 9
[5] => 2
[team2] => 2
[6] => JohnDoe B
[t2name] => JohnDoe B
[7] => 1
[t2pnts] => 1
[8] => 1
[p1] => 1
[9] => 3
[p1p] => 3
[10] => 3
[p1w] => 3
[11] => 2
[p2] => 2
[12] => 3
[p2p] => 3
[13] => 3
[p2w] => 3
[14] => 3
[p3] => 3
[15] => 3
[p3p] => 3
[16] => 3
[p3w] => 3
[17] => 6
[p4] => 6
[18] => 3
[p4p] => 3
[19] => 0
[p4w] => 0
[20] => 7
[p5] => 7
[21] => 3
[p5p] => 3
[22] => 0
[p5w] => 0
[23] => 8
[p6] => 8
[24] => 3
[p6p] => 3
[25] => 0
[p6w] => 0
[26] => 50
[confirmed] => 50
)
谢谢,
答案 0 :(得分:1)
你错过了价值附近的报价。此外,您还应使用htmlentities
对输出进行编码。见下文:
<?php
while ($row = mysql_fetch_array($result)) {
echo "<form action='login.php' method='POST'>";
echo "<tr>";
echo "<td align='center' valign='middle'><input type='text' name='listid' value='" . htmlentities($row['g_id']) . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='listid' value='" . htmlentities($row['t1name']) . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='listid' value='" . htmlentities($row['t2name']) . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type ='submit' value ='Confirm game'></td>";
echo "</form>";
echo "</tr>";
}
?>