-1

我正在尝试从数据库中检索记录并将它们放入表中。我想要一个可以做一些处理的更新按钮。这是代码。它正确输出。但是更新按钮(图像)不起作用。请帮忙

<?php
echo "</br>";
echo "<table border='1'>
<tr>
<th>Order ID</th>
<th>Customer Number</th>
<th>Order Items</th>
<th>Transaction Time</th>
<th>Amount</th>
</tr>";
$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("kaka", $con);

$sql="SELECT * FROM orders WHERE status = 'NRDY'";
$result2 = mysql_query($sql);
while($row1 = mysql_fetch_array($result2))
  {
  echo "<div class=\"update\"><form method='post' action=\"test.php\">\n";  
  echo "<tr>";
  echo "<td><input type='hidden' name='order_id' value='".$row1['order_id']."'>" .$row1['order_id']. "</td>";
  echo "<td><input type='hidden' name='cust_num' value='".$row1['cust_num']."'>" .$row1['cust_num']. "</td>";
  echo "<td><input type='hidden' name='items' value='".$row1['items']."'>" .$row1['items']. "</td>";
  echo "<td><input type='hidden' name='order_time' value='".$row1['order_time']."'>" .$row1['order_time']. "</td>";
  echo "<td><input type='hidden' name='order_id' value='".$row1['amount']."'>" .$row1['amount']. "</td>";
  //echo "<td>" . $row1['order_id'] . "</td>";
  //echo "<td>" . $row1['cust_num'] . "</td>";
  //echo "<td>" . $row1['items'] . "</td>";
  //echo "<td>" . $row1['order_time'] . "</td>";
  //echo "<td>" . $row1['amount'] . "</td>";
  echo "<td>" . "<input type=\"image\" src=\"images/update.png\" alt=\"Update Row\" class=\"update\" title=\"Update Row\">\n" . "</td>";
  echo "</tr>";
  echo "</form></div>";  
  }

 echo "</table>";
?>

这是test.php

<?php
echo $_POST['order_id'];
?>
4

1 回答 1

1

使用验证器。不允许在表格行周围包裹 div 或表单。一些浏览器通过移动 div/form 使其位于表格之外(将内容留在后面)从这个错误中恢复。因此,您的输入不在表单内,因此不应期望执行任何操作。

于 2012-09-21T06:27:32.980 回答