<?php
include("server1.php");
$errormsg="";
if ($stmt = $mysqli2->prepare("select years"
   . " from document order by years asc")){
  $stmt->execute();
  $stmt->bind_result($col1);
  $stmt->store_result();
  if($stmt->num_rows<1)
        $errormsg = "沒有資料!!!";
 }
?>
<form id="form1" name="form1" method="get" 
      action="<?php  echo htmlentities($_SERVER['PHP_SELF']); ?>">
<select name="years" size="1" onchange="document.form1.submit()">
    <option>請選擇</option>
     <?php 
   while ($stmt->fetch()) {
     echo "<option value='$col1' >$col1</option>"; 
	 }   
   $stmt->close();	 	
?>
</select>年</form> 