Here's an example of what you're asking for. The first time the script is called it displays the attorney names. The user selects a name and clicks Submit. The selected name is used to obtain the case numbers for that attorney. Those case numbers are displayed in a drop down box in a separate form and the previously selected attorney name is displayed in it's drop down list. If the user selects a different attorney name and clicks Submit then the case number drop down box is recreated with that attorney's cases and that attorney's name is displayed in it's drop down list.
Hope this helps.
Hank
++++++++++++++++++++++++++++++
$sel_c = pg_exec($db_conn, "SELECT distinct(d_counsel) FROM deft_counsel order by d_counsel");
print("<form method=post action=\"/xxxx/deft_counsel_cases.php\">\n");
print("<table width=400 border=0><tr align=center><td>\n");
print("<select size=1 name=d_counsel>\n");
$num_c = pg_numrows($sel_c);
for($i=0; $i<$num_c; $i++) {
$arr1 = pg_fetch_array($sel_c, $i);
if ($d_counsel == trim($arr1["d_counsel"])) {
printf("<option value=\"%s\" selected>%s\n", trim($arr1["d_counsel"]), trim($arr1["d_counsel"]));
}
else {
printf("<option value=\"%s\">%s\n", trim($arr1["d_counsel"]), trim($arr1["d_counsel"]));
}
} / END FOR LOOP /
print("</select></td></tr></table>\n");
print("<input type=submit value=\"Select Counsel\"></form>\n");
print("<br><font size=3 color=990000>Select a Counsel from the drop down list and click the Select Counsel button</font><p>\n");
if (strlen($d_counsel) > 0) { / If we have selected an attorney name /
print("<form method=post action=\"/xxxx/process_srch_case.php\">\n");
$sel_id = pg_exec($db_conn, "select deft_id from deft_counsel where d_counsel = '$d_counsel'");
$num_ids = pg_numrows($sel_id);
print("<font size=3>Case Nbr - Defendant Name</font>\n");
print("<table width=400 border=0><tr align=center><td>\n");
print("<select size=1 name=case_nbr>\n");
for ($j=0; $j<$num_ids; $j++) {
$arr_id = pg_fetch_array($sel_id, $j);
$deft_id = $arr_id["deft_id"];
$sel_case = pg_exec($db_conn, "SELECT deft, case_nbr FROM defendant where deft_id = $deft_id order by case_nbr");
$num_cases = pg_numrows($sel_case);
for($i=0; $i<$num_cases; $i++) {
$arr1 = pg_fetch_array($sel_case, $i);
printf("<option value=\"%s\">%s - %s\n", trim($arr1["case_nbr"]), trim($arr1["case_nbr"]), trim($arr1["deft"]));
}
}
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 counsel</font>\n");
}