0

I would like to open a form using a PHP URL by id. The URL looks like this.

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

And receiving the id into PostgreSQL like this.

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

I need the forms input fields to be filled with database data by the id in the database. What am I missing?

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

1 Answers1

1

Try debugging like so

echo print_r($row);

Additionally, you might want to add a limit. Tell us what you get.

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

But you should review the data structure returned by pg_fetch_assoc($result);

You'll want to map the keys you need to the input fields which should be revealed (or anomalies revealed) via the print_r function.

DrM
  • 1,092
  • 1
  • 8
  • 11