title: How to use jquery autocomplete to load data from mysql database?
body: <p>I want to make one search box which display list of  matched records from database related to which we have type in our box,
  I have Use Jquery's Auto Complete.
  That's OK, but I want to select records from my database Table instead manually give it in var availableTags.
  I want to get records from DB in var availableTags in following code..</p>
  
  <p>here is my code with Smarty Templates.....</p>
  
  <p>My Html:(searchh.tpl)</p>
  
  <pre><code>{block name=head}
      &lt;title&gt;Untitled Document&lt;/title&gt;
        &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /&gt;
        &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
        &lt;script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"&gt;&lt;/script&gt;
        &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt;
        &lt;script&gt;
  
      }   
        $(function() {
          var availableTags = [
            "Python",
            "Ruby",
            "Scala",
            "Scheme"
          ];
          $( "#tags" ).autocomplete({
            source: availableTags     
          });
        });
  
        &lt;/script&gt;
      {/block}
      {block name=body}
      &lt;div class="ui-widget"&gt;
        &lt;label for="tags"&gt;Tags: &lt;/label&gt;
        &lt;input id="tags" /&gt;
      &lt;/div&gt;
      {/block}
  </code></pre>
  
  <p>My php :(searchh.php)</p>
  
  <pre><code>&lt;?php 
      include("include/config.inc.php");
      $pArray = 0;
      $search = isset($_POST['search']) &amp;&amp; ($_POST["search"] != "") ? $_POST['search']:''; 
      if($search != '')
      {   
        $query="select * from party where partyName like '%$search%' ";
        $result = mysql_query($query);
        $pArray = array();
        $n = 0;
        while ($row = mysql_fetch_array($result)) 
        {
          $pArray[$n]['partyId']   = $row['partyId'];
          $pArray[$n]['partyName'] = $row['partyName'];
          $n++;
        }
      }
      include("./bottom.php");
      $smarty-&gt;assign("search",$search);
      $smarty-&gt;assign("pArray",$pArray);
      $smarty-&gt;display('searchh.tpl');
      ?&gt;
  </code></pre>
  
  <p>If Anybody can help, It will very grateful to me.
  Thanks..</p>