Okay, a couple things to think about ...
First, your multiline html text might be better created using PHP's heredoc format
print <<<ENDLINE
<td width="200">
<select name="hospital1">
<option value=""> -- Select -- </option>
ENDLINE;
while ( $row = mysql_fetch_object( $sqlhosp_result ) ) {
print <<<ENDLINE
<option value="$row->HospInsCo">$row->HospInsCo</option>
ENDLINE;
} You can use anything, not justENDLINE/ENDLINE; and of course you can use echo if you prefer, but I like print coming from a perl background.
Second, you are grabbing all of your values in a while loop, so if you need to use those values more than once, you should put them into an array and then reuse the array ...
while ( $row = mysql_fetch_object( $sqlhosp_result ) ) {
$rows[] = $row->HospInsCo;
}
print <<<ENDLINE
<td width="200">
<select name="hospital1">
<option value="">
ENDLINE;
foreach ( $rows as $row ) {
print <<<ENDLINE
<option value="$row">$row</option>
ENDLINE;
}
Finally, if you want to change the select-options based on what a user selects from the first select box, you will either need tore-submit/reload the page, or use javascript to do the dirty work. Since PHP only works on the server and is done after the page has loaded.
Hope this makes sense and helps