#include <infocon.style>
#include "hwdb.inc"
#include "form.inc"

<page func=InfoCon title="Hardware Database">

<?
<dbconnect>

  if (isset($_GET[id])) {
    $query = sprintf ("SELECT * FROM compound WHERE id = %d", $_GET[id]);
    $sth = pg_exec ($dbh, $query) or die("Cannot issue query!");

    if (pg_NumRows ($sth) > 0) {
      $row = pg_fetch_array ($sth, 0);
    }
  }
?>

<form method=post action=update.php>
<input type=hidden name=formtype value="compound">
<? if (isset($_GET[id])) { ?>
<input type=hidden name=id value="<? echo $_GET[id]; ?>">
<? } ?>
<center><table cellpadding=0 cellspacing=1>

<row_input	name=name
		title="<b>Compound</b>"
		value="<? echo $row['name']; ?>"
		>
<row_input	name=hostname
		title="<b>Hostname</b>"
		value="<? echo $row['hostname']; ?>"
		>
<row_input	name=ip
		title="<b>IP</b>"
		value="<? echo $row['ip']; ?>"
		>
<row_input	name=ident
		title="<b>Ident</b>"
		value="<? echo $row['ident']; ?>"
		>
<?
    $query = "SELECT id,name FROM organisation ORDER BY name";
    $sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!");
    if (pg_NumRows ($sth) > 0) {
	$row_select_keys = array();
	$row_select_values = array();

	for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
	    $srow = pg_fetch_array ($sth, $nr);
	    $row_select_keys[] = $srow['id'];
	    $row_select_values[] = $srow['name'];
	}
    }
?>
<row_select	name=location
		title="<b>Location</b>"
		selected="$row['location']"
		>
<?
  $row_select_keys = array('in use','defunct','unused');
  $row_select_values = array('in use','defunct','unused');
?>
<row_select	name=status
		title="<b>Status</b>"
		selected="$row['status']"
		>

<row_textarea	name=comment
		title="<b>Comment</b>"
		value="<? echo $row['comment']; ?>"
		rows=7
		>


<row_submit>

</table></center></form>

</page>

# Local variables:
# mode: text
# mode: auto-fill
# end:
