<link rel="stylesheet" href="scripts/jquery/themes/redmond/jquery.autocomplete.css">
<script src="scripts/jquery/ui/jquery.autocomplete.js"></script>
<script>
$(document).ready(function()
{
$("#txtfrom").autocomplete("get_search_values.php?",
{
selectFirst: true
});
});
</script>
<input type="text" name="txtfrom" id="txtfrom" class="area-point-text-input"/>
inc_get_search_values.php code
$term=$_GET['q'];
$term=trim(strip_tags(mysql_real_escape_string($term)));
$searchByNameStr = "SELECT name, outer_postcode, id, area_type, full_postcode, outer_postcode, is_address FROM a_area_points WHERE is_display = '1' AND (name LIKE '".$term."%') LIMIT 300";
$searchByNameResult = mysql_query($searchByNameStr);
$searchByNameResultCount = mysql_num_rows($searchByNameResult);
if($searchByNameResultCount>0){
while ($row = mysql_fetch_array($searchByNameResult,MYSQL_ASSOC))
{
$name = ucwords(strtolower($row['name']));
$outer_postcode = $row['outer_postcode'];
$area_type = $row['area_type'];
if($area_type == 'AIRPORT'){
$outer_postcode = "";
$label = "$name";
}else{
$label = "$name, $outer_postcode";
}
echo $label."\n";
}
}
<script src="scripts/jquery/ui/jquery.autocomplete.js"></script>
<script>
$(document).ready(function()
{
$("#txtfrom").autocomplete("get_search_values.php?",
{
selectFirst: true
});
});
</script>
<input type="text" name="txtfrom" id="txtfrom" class="area-point-text-input"/>
inc_get_search_values.php code
$term=$_GET['q'];
$term=trim(strip_tags(mysql_real_escape_string($term)));
$searchByNameStr = "SELECT name, outer_postcode, id, area_type, full_postcode, outer_postcode, is_address FROM a_area_points WHERE is_display = '1' AND (name LIKE '".$term."%') LIMIT 300";
$searchByNameResult = mysql_query($searchByNameStr);
$searchByNameResultCount = mysql_num_rows($searchByNameResult);
if($searchByNameResultCount>0){
while ($row = mysql_fetch_array($searchByNameResult,MYSQL_ASSOC))
{
$name = ucwords(strtolower($row['name']));
$outer_postcode = $row['outer_postcode'];
$area_type = $row['area_type'];
if($area_type == 'AIRPORT'){
$outer_postcode = "";
$label = "$name";
}else{
$label = "$name, $outer_postcode";
}
echo $label."\n";
}
}
No comments:
Post a Comment