Seach

how to create a autocomplete text box using php,jquery,mysql

select.php
<?php
@mysql_connect("localhost","root","");
@mysql_select_db("example");
$query="select * from auto";
$tempdata=@mysql_query($query);
$name=array();
while($data=@mysql_fetch_assoc($tempdata))
{
$name[]=$data["name"];
}
echo json_encode($name);
?>

page.php
<head>
    <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
      <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>


    <div class="ui-widget">
    <input type="text" id="automplete-1">
    </div>

<script type="text/javascript">
$(document).ready(function()
{
    var name=<?php include 'select.php'; ?>;
    $("#automplete-1").autocomplete({
        source: name,
        autoFocus:true
    });
});
</script>