Here's the way I skinned this cat. The first time the script is run only one drop down list is displayed. When the user selects from the drop down list, the script runs again but now the second drop down list is displayed. This works for me because the contents of the second list are determined by the item selected in the first list.
Hank
+++++++++++++++ snippet ++++++++++++++
<?php
/** all_cases_deft.php ***/
...
/************ FIRST DROP DOWN LIST *************/
/ First I display all the names of the defendants ****/
print("<form method=post action=\"/earthquake/all_cases_deft.php\">\n");
print("<table width=400 border=0><tr align=center><td>\n");
print("<select size=1 name=deft>\n");
$num_defts = pg_numrows($sel_defts);
for($i=0; $i<$num_defts; $i++) {
$arr1 = pg_fetch_array($sel_defts, $i);
if ($deft == trim($arr1["deft"])) {
printf("<option value=\"%s\" selected>%s\n", trim($arr1["deft"]), trim($arr1["deft"]));
}
else {
printf("<option value=\"%s\">%s\n", trim($arr1["deft"]), trim($arr1["deft"]));
}
} / END FOR LOOP /
print("</select></td></tr></table>\n");
print("<input type=submit value=\"Select Defendant\"></form>\n");
print("<br><font size=3 color=990000>Select a Defendant from the drop down list and click the Select Defendant button</font>\n");
/****************** SECOND DROP DOWN LIST **********************/
/ If a defendant name was passed to this script (which calls itself) then
I display all the case numbers for this particular defendant ******/
if (strlen($deft) > 0) {
print("<form method=post action=\"/earthquake/process_srch_case.php\">\n");
$sel_case = pg_exec($db_conn, "SELECT case_nbr FROM defendant where deft = '$deft' order by case_nbr");
$num_cases = pg_numrows($sel_case);
printf("<font size=5>%d case(s) for %s</font>\n", $num_cases, $deft);
print("<table width=400 border=0><tr align=center><td>\n");
print("<select size=1 name=case_nbr>\n");
for($i=0; $i<$num_cases; $i++) {
$arr1 = pg_fetch_array($sel_case, $i);
printf("<option value=\"%s\">%s\n", trim($arr1["case_nbr"]), trim($arr1["case_nbr"]));
} / END FOR LOOP /
print("</select></td></tr></table>\n");
print("<input type=submit value=\"View Case\"></form>\n");
print("<p><font size=3 color=990000>Select a Case Number to view or go up and select a different Defendant</font>\n");
}
...
?>