frshjb373 Posted September 3, 2012 Share Posted September 3, 2012 I am using the search query below to populate my jquery auto complete. The image shows up great in the search, but when I select an item from my search, it populates the text box with the href code as well. For example: <img src="images/catalog-images/1211767440.png" width="100" >Apple iPhone 4S - 32GB Just trying to figure out how to remove the image link after item is selected. Any help is much appreciated. Thank you in advance! <?php $q=$_GET['q']; $my_data = str_replace(array("'", '"'), array("", ""), $q); //$my_data=mysql_real_escape_string($q); $mysqli=mysqli_connect($DB_host,$DB_user,$DB_pass,$DB_name) or die("Database Error"); $sql="SELECT * FROM cell_brands WHERE name LIKE '%$my_data%' OR keyword1 LIKE '%$my_data%' OR keyword2 LIKE '%$my_data%'"; $result = mysqli_query($mysqli,$sql) or die(mysqli_error()); if($result) { while($row=mysqli_fetch_array($result)) { echo "<img src=\"images/catalog-images/" . $row["photo-image"] . "\" width=\"100\" >"; echo $row['name']."\n"; } } //mysql_close($mysqli); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted September 3, 2012 Share Posted September 3, 2012 No where in your code or example output is any html anchor tag. You are however echoing an image tag here: echo "<img src=\"images/catalog-images/" . $row["photo-image"] . "\" width=\"100\" >"; Quote Link to comment Share on other sites More sharing options...
frshjb373 Posted September 3, 2012 Author Share Posted September 3, 2012 I tried putting an anchor tag on the image and then anchored it as the value in the text box, but that shows the code for both the image and the anchor html code. Any suggestions? Quote Link to comment Share on other sites More sharing options...
trq Posted September 3, 2012 Share Posted September 3, 2012 Yeah, don't echo what you don't want displayed. Quote Link to comment Share on other sites More sharing options...
frshjb373 Posted September 4, 2012 Author Share Posted September 4, 2012 I very much appreciate the help, but sorry, I may not be following you...If I don't echo it, the image won't show up in the dropdown. Quote Link to comment Share on other sites More sharing options...
trq Posted September 4, 2012 Share Posted September 4, 2012 I don't understand what your actual issue is. You either want the image to show or you don't. Quote Link to comment Share on other sites More sharing options...
frshjb373 Posted September 4, 2012 Author Share Posted September 4, 2012 I've attached images for you. If the image is echoed it is seen in the autocomplete dropdown when searched, but when you actually select it, the img code is also shown in the text field. I'd like to find a way to remove that image code after an item is selected so all the user sees is the item name. Does that make sense? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 You'll probably need to use javascript, if I understand your question. 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.