I work in a hospital and I am using php, postgres and apache to replace
old paradox databases. I have made a form that contains a dropdown
menu of the hospital units so I can choose the group of patient based
on the unit they are on. For some reason my code has each unit
appearing 2 times in the drop down so the dropdown looks like this
unit1
unit1
unit2
unit2
and so on. I have tested the query in the pgadim query window and I
get only one occurance. then I wrote the simple script:
?php
pg_connect("hos t=localhost dbname=liberty user=postgres
password=passwo rd") or die;
$qunit = pg_query("SELEC T unitid, unitname FROM li_unit ORDER BY
unitname");
while($myunits= pg_fetch_array( $qunit)){
$eachid=$myunit s["unitid"];
$eachunit=$myun its["unitname"];
echo "$eachid $eachunit<br>\n ";
}
?>
and I get the simple out put of
1 unit1
2 unit2
3 unit3
4 unit4
Yet the below code gives me the double occurance of each unit. here is
the code.
<html>
<head>
<body>
<form name="unitchoic e" method="post" action="<?php print
$_SERVER['PHP_SELF']?>">
<select name="homeunits ">
<?php
pg_connect("hos t=localhost dbname=liberty user=postgres
password=passwo rd") or die;
$qunit = pg_query("SELEC T unitid, unitname FROM li_unit ORDER BY
unitname");
while($myunits= pg_fetch_array( $qunit)){
$eachid=$myunit s["unitid"];
$eachunit=$myun its["unitname"]; ?>
<option value=<?php echo $eachunit;?>><? php echo
$eachunit;?></option>
<?php
}
?>
</select>
<input type="Submit" name="updateuni t" value="Change Unit">
</form>
</body>
</head>
</html>
Any suggestions?
old paradox databases. I have made a form that contains a dropdown
menu of the hospital units so I can choose the group of patient based
on the unit they are on. For some reason my code has each unit
appearing 2 times in the drop down so the dropdown looks like this
unit1
unit1
unit2
unit2
and so on. I have tested the query in the pgadim query window and I
get only one occurance. then I wrote the simple script:
?php
pg_connect("hos t=localhost dbname=liberty user=postgres
password=passwo rd") or die;
$qunit = pg_query("SELEC T unitid, unitname FROM li_unit ORDER BY
unitname");
while($myunits= pg_fetch_array( $qunit)){
$eachid=$myunit s["unitid"];
$eachunit=$myun its["unitname"];
echo "$eachid $eachunit<br>\n ";
}
?>
and I get the simple out put of
1 unit1
2 unit2
3 unit3
4 unit4
Yet the below code gives me the double occurance of each unit. here is
the code.
<html>
<head>
<body>
<form name="unitchoic e" method="post" action="<?php print
$_SERVER['PHP_SELF']?>">
<select name="homeunits ">
<?php
pg_connect("hos t=localhost dbname=liberty user=postgres
password=passwo rd") or die;
$qunit = pg_query("SELEC T unitid, unitname FROM li_unit ORDER BY
unitname");
while($myunits= pg_fetch_array( $qunit)){
$eachid=$myunit s["unitid"];
$eachunit=$myun its["unitname"]; ?>
<option value=<?php echo $eachunit;?>><? php echo
$eachunit;?></option>
<?php
}
?>
</select>
<input type="Submit" name="updateuni t" value="Change Unit">
</form>
</body>
</head>
</html>
Any suggestions?
Comment