// This is my test page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="includes18/jQuery/css/plt-theme/jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
<script src="includes18/jQuery/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="includes18/jQuery/js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#send_to").autocomplete({
source: "find_ships.php",
minLength: 2,
select: function(event, ui) {
}
});
});
</script>
</head>
<body>
<p>Autocomplete Example</p>
<div class="ui-widget">
<label for="send_to">To: </label>
<input id="send_to" size="60" />
</div>
</body>
</html>
//This is my PHP script
<?php
require_once('../Connections/BBA.php');
$term = $_GET['q'];
mysql_select_db($database_BBA, $BBA);
$query = "SELECT username FROM users WHERE username LIKE '$term%'";
$query_result = mysql_query($query, $BBA) or die(mysql_error());
$results = array();
//This creates a json array
while($row = mysql_fetch_assoc($query_result)) {
array_push($results, $row['username']);
}
print json_encode($results);
?>
|