In index.php I have:
<!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>Clientbook</title>
<script type="text/javascript" src="dropdown/jquery/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="dropdown/jquery/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$('#zipsearch').autocomplete({source:'dropdown/suggest_zip.php', minLength:1});
});
</script>
<link rel="stylesheet" href="dropdown/jquery/css/smoothness/jquery-ui-1.8.2.custom.css" />
<style type="text/css"><!--
/* style the auto-complete response */
li.ui-menu-item { font-size:12px !important; }
--></style>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Geneva, sans-serif;
font-size: small;
color: #069;
}
-->
</style></head>
<body marginheight="0" marginwidth="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height:20px;"><td bgcolor="#993399" align="center">
<table width="75%" border="0"><tr><td align="left" width="200px"><p style="color:#FFF; margin:0;"></p></td><td align="left"><form onSubmit="return true;" action="index.php">
<input style="width:400px;" id="zipsearch" type="text" />
</form> </td>
</tr>
</table>
</td></tr><tr><td align="center">
<table width="75%" border="0"><tr><td width="200px"></td><td valign="top">Content
</td><td width="300px"></td></tr></table>
</td></tr>
</table>
</body>
</html>
In suggest_zip.php I have:
<?php
if ( !isset($_REQUEST['term']) )
exit;
$dblink = mysql_connect('server', 'user', 'pass') or die( mysql_error() );
mysql_select_db('database');
$rs = mysql_query('select Name, Surname from people where Name like "'. mysql_real_escape_string($_REQUEST['term']) .'%" order by Name asc limit 0,10', $dblink);
$data = array();
if ( $rs && mysql_num_rows($rs) )
{
while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
{
$data[] = array(
'label' => $row['Name'] .' '. $row['Surname'] ,
'value' => $row['ID']
);
}
}
echo json_encode($data);
flush();