title: Select input with values from mysql database
body: <p>I want to use <a href="http://ivaynberg.github.io/select2/" rel="nofollow">this jquery plugin</a> to get values from database...</p>
  
  <p>I create jquery ajax code and HTML to get values from database:</p>
  
  <pre><code> &lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
  &lt;link href="http://ivaynberg.github.com/select2/select2-3.3.2/select2.css" rel="stylesheet" type="text/css" /&gt;
  &lt;script src="http://ivaynberg.github.com/select2/select2-3.3.2/select2.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
  &lt;select id="test" style="width:200px;"&gt;
                &lt;option value=""&gt;&lt;option&gt;
  
      &lt;/select&gt;
  
  
          &lt;script&gt;
  $('#test').select2({
      ajax: {
          dataType: "json",
          url: "json.php",
          results: function (data) {
              return {results: data};
          }
      }
  });
  
  &lt;/script&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>and json.php code:</p>
  
  <pre><code>&lt;?php
  $pdo=new PDO("mysql:dbname=ddd;host=localhost","ddd","ddd");
  $statement=$pdo-&gt;prepare("SELECT id,ime_prezime FROM radnici");
  $statement-&gt;execute();
  $results=$statement-&gt;fetchAll(PDO::FETCH_ASSOC);
  $json=json_encode($results);
  echo $json;
  ?&gt;
  </code></pre>
  
  <p>when I run php code i get json:</p>
  
  <pre><code>[{"id":"1","ime_prezime":"Pera Peric"}]
  </code></pre>
  
  <p>s the problem is not with php code... what is wrong in my html/jquery code?</p>
  
  <p>I dont get anything, I cant fetch values from json.php file</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I find error is was json format, but now I cant save values that I get , so when I click values just disapear...</p>
  
  <pre><code>&lt;input id="test" style="width:300px;"&gt;
  &lt;select multiple id="test" style="width:300px"&gt;&lt;/select&gt;
  
  
  
  
          &lt;script&gt;
          function formatValues(data) {
      return data.ime_prezime;
  }
  $('#test').select2({
      ajax: {
          dataType: "json",
          url: "json.php",
          results: function (data) {
              return {results: data};
          }
      },
      formatResult: formatValues
  });
  
  &lt;/script&gt;
  </code></pre>