从表格中的表格发布

时间:2012-09-21 06:25:22

标签: php html forms html-table

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

<?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'];
?>

1 个答案:

答案 0 :(得分:1)

使用a validator。不允许在表行周围包装div或表单。有些浏览器通过移动div /表单从这个错误中恢复,因此它在表格之外(将内容留在后面)。因此,您的输入不在表格内,因此不应该做任何事情。

相关问题