Here is my code
autocomplete.php
<html>
<head>
<script type="text/javascript"
src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript"
src="js/jquery.autocomplete.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#name").autocomplete({
source:'test.php',
minLength:1,
selectFirst: true
});
});
</script>
</head>
<body>
<form method="post" action="">
Name : <input type="text" id="name" name="name" />
</form>
</body>
<html>
test.php
<?php
$my_string =$_GET['q'];
//echo $my_string;
syslog($priority, $my_string);
try {
// Connect to MongoDB
$conn = new Mongo('localhost');
// connect to test database
$db = $conn->mydb;
// a new products collection object
$collection = $db->QuoteCollections;
$quote_array = array(
'Author' => $my_string,
);
$cursor = $collection->find($quote_array);
//$json=$cursor;
foreach ($cursor as $obj)
{
//$json[]=array(
//'value'=> $student["Author"],
//'label'=>$student["Author"]
// );
echo 'Name: ' . $obj['Author'] . "
<br>";
echo $row['Author']."
";
}
//echo json_encode($json);
// close connection to MongoDB
$conn->close();
}
catch ( MongoConnectionException $e )
{
// if there was an error, we catch and display the problem here
echo $e->getMessage();
echo "error at mongoconexe";
}
catch ( MongoException $e )
{
echo $e->getMessage();
echo "error at mongoconeException";
}
?>
i cannot get the result, i referd these links
http://phpseason.wordpress.com/2013/02/13/php-autocomplete-tutorial-using-jquery/
http://tutsforweb.blogspot.in/2012/05/auto-complete-text-box-with-php-jquery.html
i placed both js files inside a js folder
please help me
Thanks