Search the Community
Showing results for tags 'jquery autocomplete'.
-
i'm using jquery autocomplete with a remote php script. this code works fine: db_connect(); $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends $qstring = "SELECT id,nominativo,indirizzo,telefono,fax,e_mail FROM legale WHERE nominativo LIKE '%".$term."%'"; $result = mysql_query($qstring);//query the database for entries containing the term while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//loop through the retrieved values { $row['nominativo']=htmlentities(stripslashes($row['nominativo'])); $row['indirizzo']=htmlentities(stripslashes($row['indirizzo'])); $row['telefono']=htmlentities(stripslashes($row['telefono'])); $row['fax']=htmlentities(stripslashes($row['fax'])); $row['e_mail']=htmlentities(stripslashes($row['e_mail'])); $row['id']=(int)$row['id']; $row_set[] = $row;//build an array } echo json_encode($row_set);//format the array into json data this one doesn't: $db=db_connect_param(); $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends if($_GET['what']=="legale") $qstring = "SELECT id,nominativo,indirizzo,telefono,fax,e_mail FROM legale WHERE nominativo LIKE ?"; $search="%$term%"; $sql=$db->prepare($qstring); $sql->bind_param('s',$search); $sql->execute(); $sql->bind_result($id,$nominativo,$indirizzo,$telefono,$fax,$e_mail); //build an array while($sql->fetch()) { $row['nominativo']=htmlentities(stripslashes($nominativo)); $row['indirizzo']=htmlentities(stripslashes($indirizzo)); $row['telefono']=htmlentities(stripslashes($telefono)); $row['fax']=htmlentities(stripslashes($fax)); $row['e_mail']=htmlentities(stripslashes($e_mail)); $row['id']=(int)$id; $row_set[]=$row; } echo json_encode($row_set);//format the array into json data*/ what's the difference? the json returned seems the same.