title: Getting filtered results by JQuery UI autocomplete
body: <p>I don't know what I'm doing wrong. I tried to use autocomplete with json, but I always get the complete data. I expect filtered data from the user input.</p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>$( "#tags" ).autocomplete({
      source: "/script.php",
      minLength: 2,
      select: function(event, ui) {
          var url = ui.item.id;
          if(url != '#') {
              location.href = '/blog/' + url;
          }
      },
      open: function(event, ui) {
          $(".ui-autocomplete").css("z-index", 1000);
      }
  });
  </code></pre>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>$result = $paed_db-&gt;prepare('SELECT data FROM table');
  $result-&gt;execute();
  $a_json = array();
  while($data = $result-&gt;fetch(PDO::FETCH_OBJ)) {
      $a_json_row["value"] = $data-&gt;data;
      array_push($a_json, $a_json_row);
  }
  
  $json = json_encode($a_json);
  print $json;
  exit;
  </code></pre>