PHP Code:
  $page .= "<select name=\"year\">\n<option selected value=\"".$year."\">".$year."</option>\n";
   
$query "SELECT DISTINCT " .
           
"year " .
           
"FROM {{table}} " .
           
"ORDER BY year ASC";
  
$result doquery($query"teams");
  while (
$row mysql_fetch_array($result)) { $page .= "<option value=\"".$row['year']."\">".$row['year']."</option>\n"; }
$page .= <<<END
        </select>
      </td>
      <td>State: 
END;
  
$page .= "<select name=\"state\">\n<option selected value=\"".$state."\">".$state."</option>\n";
  
$query "SELECT DISTINCT " .
           
"state " .
           
"FROM {{table}} " .
           
"ORDER BY state ASC";
  
$result doquery($query"teams");
  while (
$row mysql_fetch_array($result)) { $page .= "<option value=\"".$row['state']."\">".$row['state']."</option>\n"; } 
Should there be two queries like so in this? Could it just be made like:

PHP Code:
  $query "SELECT DISTINCT " .
           
"year, state " .
           
"FROM {{table}} " .
           
"ORDER BY year, state ASC"
If so, how would you reset $result to use it twice?