【发布时间】:2013-06-25 18:28:24
【问题描述】:
<?php
$pvp=mysql_query("SELECT * FROM characters ORDER BY level DESC");
echo "<table><tr><th>Character</th><th>Level</th><th>Tribe</th></tr>";
while ($row = mysql_fetch_array($pvp)) {
echo "<tr><td>".($row['charname'])."</td><td>".($row['level'])."</td><td>".($row['tribe'])."</td><td><form action='/scripts/pvp.php' method='post'><input type='submit' name='pvp' value='Battle!'></form></td></tr>";
}
echo "</table>";
?>
在这个脚本中,我循环遍历一个数组并显示存储在一个变量 ($pvp) 中的所有数据。我想在每一行的末尾添加一个输入按钮,允许我将该特定行发布到另一个页面以在另一个脚本中使用。我该怎么做?
【问题讨论】:
-
你可以像填充表格一样使用 PHP 填充表单输入:
<input type="text" name="charname" value="<?=$row['charname']?>" />