I have created autocomplete ajax search for a web site which auto complete organization names and addresses seperatly, but i want it to validate , when someone search organ
For organization name
$searcho=$_GET["term"];
$seachArray = explode(',',$searcho);
$q='';
foreach($seachArray as $term){
$q .=" title like '%".trim($searcho)."%' or ";
}
$q =substr($q,0 ,-3);
$query=mysql_query("SELECT * FROM sltdb_cddir_content where ($q) AND categories_id=80 ");
$json=array();
while($display=mysql_fetch_array($query)){
$json[]=array(
'label'=> $display['title'],
'value' => $display['title'],
);
}
Edited after your comment
$searcho=$_GET["term"];
$query=mysql_query("SELECT * FROM sltdb_cddir_content where title like '%".$searcho."%'AND categories_id=80 ");
$json=array();
while($display=mysql_fetch_array($query)){
$json[]=array(
'label'=> $display['title'],
'value' => $display['title'],
'address' =>$display['fulladdress'],
);
}
This will include address into your result. Now you have to work in your js as given below.
jQuery("#searcho").autocomplete({
source:'<?php echo JURI::root().'modules/mod_jomdirectory_search/tmpl/gov.php'; ?>',
minLength:1
select: function (event, ui) {
var address = ui.item.address;
jQuery("#addresso").val(address);
}
});
Ref -- Jquery autocomplete on select event