title: Populate drop down list from MySQL column data
body: <p>I am currently having trouble displaying the entries in a column of my database in a drop down list.</p>
  
  <p>The code below... is half working i guess...
  When I run it, the drop down list gives me 6 options (the column in my database also has 6 columns) Now I just need to get the names to show up! </p>
  
  <p>All help is appreciated!</p>
  
  <pre><code>&lt;select id="teamlist" name="teamlist"&gt;
  &lt;?php
    $pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
    #Set Error Mode to ERRMODE_EXCEPTION.
    $pdo-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  
    $stmt = $pdo-&gt;prepare('Select teamname from members');
    $stmt-&gt;execute();
    while($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
      echo "&lt;option&gt;{$row['teamname']}&lt;/option&gt;";
    }
  ?&gt;
  &lt;/select&gt; 
  </code></pre>