title: Dropdown List from MySQL Column using mysqli
body: <p>I have a MySQL table named <code>Users</code> with columns <code>Name</code> and <code>NameID</code>. </p>
  
  <p>Like...<br>
  Name | NameID<br>
  Brad | bd<br>
  Tom | ts</p>
  
  <p>I'm trying to pull the all the <code>Name</code> values and have them populate a dropdown list using mysqli. I'm running into problems and hoping someone here can help.</p>
  
  <p>I'm new to mysqli, so struggling a bit here. Here's the code..</p>
  
  <p>connect.php...</p>
  
  <pre><code>&lt;?php
  
  $dbname = 'mydabase';
  $dbuser = 'myuser';
  $dbpass = 'mypass';
  
  ?&gt;
  </code></pre>
  
  <p>In index.php...</p>
  
  <pre><code>&lt;?php
  include ("connect.php");
  
  $db = new mysqli('localhost', $dbuser, $dbpass, $dbnam);
  if (!$db) {
    exit('Connect Error (' . mysqli_connect_errno() . ') '
         . mysqli_connect_error());
  } 
  ?&gt;
  
      &lt;div class="label"&gt;Select Name:&lt;/div&gt;
  
      &lt;select name="names"&gt;
      &lt;option value = ""&gt;---Select---&lt;/option&gt;
      &lt;?php
      $queryusers = "SELECT `Name` FROM `Users` ";
      $db = mysqli_query($queryusers);
      while ( $d=mysqli_fetch_assoc($db)) {
        echo "&lt;option value='{".$d['Name']."}'&gt;&lt;/option&gt;";
      }
      ?&gt;
        &lt;/select&gt;  
  </code></pre>