title: Populate dropdown with MySQL query results (PHP/MySQL)
body: <p>so as the title says.....</p>
  
  <p>here is the code I currently wrote thinking it would work and it doesnt :(</p>
  
  <p>note my session userid etc is working as I can get it to print out in another field in the form so thats not the problem, but my dropbox just seems to have nothing in it. (i have created the data on the database with the user_id matching of which I am logged in with)</p>
  
  <pre><code>$userid = $_SESSION['myuserid'];
  //run query to database
  $query = "SELECT * FROM test_groups_tb WHERE user_id='$userid'";
  mysql_query($query) or die(mysql_error());
  
  while($row = mysql_fetch_assoc($query))
      {
      $dd .= "&lt;option value='{$row['group_id']}'&gt;{$row['group_name']}&lt;/option&gt;";
      } 
  </code></pre>
  
  <p>this is then used in the html:</p>
  
  <pre><code>&lt;select name="t_group"&gt;&lt;? echo $dd; ?&gt;&lt;/select&gt;
  </code></pre>
  
  <p>can somebody help me out?</p>
  
  <p>thanks</p>