autocomplete with php and mysql for one value
What is the easiest way?
Can I do it in php file?
while($row = mysql_fetch_array($query))
{
$results[] = array('label' => $row['name']);
}
echo json_encode($results);
If we run this page, the output is as follows:
[{"label":"moen"},{"label":"omid"}]
And in another file:
<link rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css"
/>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ $("#artist").autocomplete({source:
"processed.php" }); });
</script>
What is the problem in this code?
Write each word in the field, it shows all the values​​.