here's some hurried pseudocode that suggests how i have implemented foreign key selector widgets in html:
class CitySelector {
$city2show;
$sql = "select city_id, city_nm from CITY";
$_db;
function CitySelector($city2show="") {
$this->city2show=$city2show;
$this->db=[get db connection, &c]
}
function psel($city2show="") {
if ($city2show)
$this->city2show=$city2show;
$resultset = $this->db->query($sql);
print "<select name=\"cities\">\n";
while ($resultset...) {
print "<option value=\"$id\"";
if ( $id == $this->_city2show )
print "selected";
print ">$name\n";
}
print "</select>\n";
}
}
to use:
<? $c = new CitySelector($form_var_id); ?>
<table>
<tr>...
...
<td><? $c->psel(); ?></td>
...
</table>