【发布时间】:2011-06-07 04:35:55
【问题描述】:
我有一个简单的 PHP 表单,它显示来自 mysql 数据库的值的输入,并将表单结果发送到另一个页面,该页面根据GET 结果更新数据库表:
echo "<table>";
echo "<tr>";
echo " <th>Project No</th>
<th>Customer Name</th>
<th>Description</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><input value=" . $row['project_no'] . "></input></td>";
echo "<td><input value='" . $row['cust_name'] . "'></input></td>";
echo "<td><input value='" . $row['description'] . "'></input></td>";
echo "</tr>";
}
echo "</table>";
echo "<input type='submit' value='Update' />";
echo "</form>";
在updateprojects.php 我这样做时:
echo $_GET['project_no'].$_GET['cust_name'].$_GET['description'];
我没有看到任何值。这是为什么呢?
【问题讨论】:
-
print_r($_REQUEST) 带来了什么?
-
您可能想使用 HEREDOCS (php.net/heredoc) 而不是像您这样的回声进行调查。它们让生活变得更轻松,因为您不必逃避引号之类的。
-
由于您正在创建带有循环的表单输入,因此(请参阅我的回答)应该适合您,只需从数据库中获取行/记录的 id。