title: HTML select element using dynamic values from MySQL
body: <p>Here's my data:</p>
  
  <pre><code>select * from extension;
  +---------+-------+
  | ext_num | name  |
  +---------+-------+
  |  574324 | joe   |
  |  564334 | sarah |
  |  987652 | pete  |
  +---------+-------+
  3 rows in set (0.00 sec)
  </code></pre>
  
  <p>I'm trying to insert</p>
  
  <pre><code>selected="selected"
  </code></pre>
  
  <p>dynamically whilst looping through the table.</p>
  
  <pre><code>&lt;?php
  
  $mysqli = new mysqli("localhost", "user", "pass", "db");
  if ($mysqli-&gt;connect_errno) {
  echo "Failed to connect to MySQL: (" . $mysqli-&gt;connect_errno . ") " . $mysqli-&gt;connect_error;
  }
  
  if ($result = $mysqli-&gt;query("SELECT * FROM extension")) {
   print "&lt;select&gt;\n&lt;option&gt;select a value&lt;/option&gt;\n";
      while ($row = $result-&gt;fetch_assoc()) 
  {
          printf ("&lt;option value=\"%s\"&gt;%s&lt;/option&gt;\n", $row["ext_num"], $row["name"]);
      }
   print '&lt;/select&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>What's the most simple/efficient way to implement the following:</p>
  
  <pre><code>&lt;option value="987652" selected="selected"&gt;pete&lt;/option&gt;
  </code></pre>
  
  <p>(especially: selected="selected")</p>
  
  <p>into my loop using code similar to the above?</p>