techker Posted March 18, 2013 Share Posted March 18, 2013 hey guys i have this ajax autos suggest form and it works but all the suggestions have the same link.. // Query $q = @$_GET['q']; $ql = strlen($q); // Target mode $target = @$_GET['target']; // Limitation of suggestions $limit = "15"; $results = array(); $sql = "SELECT * FROM $Fiscale WHERE LEFT(Nom, $ql)='$q' ORDER BY `Nom` LIMIT $limit"; $res = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_assoc ($res)) { $results[] = $row["Nom"]."-".$row["Prenom"]; $E_ID = $row["N_Fiche"]; } if(!empty($results)) { echo "<ul>"; for($i=0;$i<count($results);$i++){ $url = @str_ireplace("%s", urlencode($results[$i]), $_GET['E_ID']); echo "<li><a href='V.php?N_F=".$E_ID."' target='".$target."'>".str_ireplace($q, $q."<b>", $results[$i])."</b></br></a></li>"; } echo "</ul>"; } } Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted March 18, 2013 Share Posted March 18, 2013 1. str_ireplace requires a string for the first parameter, not a string format. 2. Generate the URL inside of the while loop, $E_ID contains the last value from the database. Quote Link to comment Share on other sites More sharing options...
techker Posted March 18, 2013 Author Share Posted March 18, 2013 ok good thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.