title: search.php from a database for jqueryui autocomplete multiple remote widget
body: <p>I want to use jqueryui's autocomplete multiple remote widget. I've downloaded it from the website. It has a search.php page to retrieve data remotely. What I'm asking is that by default it is using array() of PHP of some already given values but I want to use it to retrieve data from a database as the user types the query.</p>
  
  <p>search.php looks like this:</p>
  
  <pre><code>&lt;?php
  
  sleep( 3 );
  // no term passed - just exit early with no response
  if (empty($_GET['term'])) exit ;
  $q = strtolower($_GET["term"]);
  // remove slashes if they were magically added
  
  if (get_magic_quotes_gpc()) $q = stripslashes($q);
  $items = array(
  "Great Bittern"=&gt;"Botaurus stellaris",
  "Little Grebe"=&gt;"Tachybaptus ruficollis",
  "Black-necked Grebe"=&gt;"Podiceps nigricollis",
  "Little Bittern"=&gt;"Ixobrychus minutus",
  "Heuglin's Gull"=&gt;"Larus heuglini"
  );
  $result = array();
  foreach ($items as $key=&gt;$value) {
      if (strpos(strtolower($key), $q) !== false) {
          array_push($result, array("id"=&gt;$value, "label"=&gt;$key, "value" =&gt; strip_tags($key)));
      }
      if (count($result) &gt; 11)
          break;
  }
  // json_encode is available in PHP 5.2 and above, or you can install a PECL module in earlier versions
  echo json_encode($result);
  ?&gt;
  </code></pre>
  
  <p>instead of this, I want the $items things to be from a database's (say my_db) table (say my table is named users) and I want to extract name field from this table.</p>
  
  <p>Any help will be greatly appreciated.</p>