title: Populate select list from JSON
body: <p>I've been looking around for a solution to what appears to be a simple problem, but am unable to find the solution...any guidance would be appreciated.</p>
  
  <p>I am attempting to build a select box using JSON object retrieved from a PHP script. The PHP script (versions.php) is running a query against a database table; code is as follows:</p>
  
  <pre><code>$posts = array();
  if(mssql_num_rows($result)) {
    while($post = mssql_fetch_assoc($result)) {
      $posts[] = $post;
    }
  }
  header('Content-type: application/json');
  echo json_encode($posts);
  </code></pre>
  
  <p>...and returns the following json structure:</p>
  
  <p>[{"version":"3.3.0"},{"version":"1.5.0"}]</p>
  
  <p>The PHP file is being called from a central JS file, which is structured as follows:</p>
  
  <pre><code>jQuery(function($){
      $.getJSON('versions.php', function(data) {
          var select = $('#release-list');
          $.each(data, function(key, val){
              var option = $('&lt;option/&gt;');
              option.attr('value', val)
                    .html(data)
                    .appendTo(select);
          });
      });
  });
  </code></pre>
  
  <p>Looking at firebug, I see lists of objects, but not the values in the array. I guess this is related to the code in the javascript file above - just not sure how to access the values from the json object.</p>
  
  <p>Thanks in advance.</p>