title: How to Redirect to Another Page in PHP based on drop down selected value/text?
body: <p>My code now works. Thanks everyone! Here is the final code in case anyone else ends up having the same trouble as I did. </p>
  
  <pre><code>&lt;?php
  mysql_connect('localhost', 'root', 'password');
  mysql_select_db('database');
  $query = "SELECT * FROM classroom";
  $result = mysql_query($query);
  ?&gt;
  &lt;select name="select1" id="select1"&gt;
  &lt;?php
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  ?&gt;
  &lt;option value="&lt;?php echo $line['classname'];?&gt;"&gt; &lt;?php echo $line['classname'];?&gt; &lt;/option&gt;
  &lt;?php
  }
  ?&gt;
  &lt;/select&gt;
  &lt;html&gt;
  &lt;script type="text/javascript"&gt;
  
  var urlmenu = document.getElementById( 'select1' );
   urlmenu.onchange = function() {
        window.open( "url/viewclass.php?classname="  + this.options[ this.selectedIndex ].value );
   };
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>