0

我想通过 id 使用 PHP URL 打开一个表单。URL 看起来像这样。

http://localhost/application/workordersystem/woformEditor.php?woid=4

并像这样将 id 接收到 PostgreSQL 中。

if (isset($_GET['woid']))
{
  $query = "SELECT * FROM orders WHERE woid='$woid'";
  $result = pg_query($query) or die(pg_error());
  $row = pg_fetch_assoc($result);
}

我需要通过数据库中的 id 用数据库数据填充表单输入字段。我错过了什么?

<input type="text" name="status" id="status" value="<?php echo $row['status']; ?>" />
4

1 回答 1

1

尝试像这样调试

echo print_r($row);

此外,您可能想要添加限制。告诉我们你得到了什么。

$query = "SELECT * FROM orders WHERE woid='$woid' LIMIT 1";

但是您应该查看 pg_fetch_assoc($result); 返回的数据结构;

您需要将所需的键映射到应该通过 print_r 函数显示(或显示异常)的输入字段。

于 2013-01-14T19:51:21.000 回答