javascript - Integrating image with jQuery AutoComplete -


so i'm working on project i'm using jquery autocomplete display search results mysql database. search results product names fetched database has product images well. how able display product images in image below ?

enter image description here

here's jquery auto complete page :

<script> $( "#birds" ).autocomplete({       source: "search.php",       minlength: 2,       select: function( event, ui ) {           log( ui.item ? "selected: " + ui.item.value + " aka " + ui.item.label :           "nothing selected, input " + this.actor );          window.location.href = './products/' + ui.item.productid;          //window.location.href = 'product_display.php?id=' + ui.item.value;        // document.testform.action = "pretravel.php?id="+ui.item.value;         //document.testform.submit();       }     });   }); </script> 

search.php

<?php include 'dbconnector.php';  // sanitise var if(isset($_get['term'])) { $term = mysql_real_escape_string($_get['term']); // add clause //$term="apple"; $query = "select `productid`, `productname` `products` `productname` '%".$term."%' order `productid`";   $result = mysql_query($query,$db) or die (mysql_error($db)); $id=0; $return=array(); while($row = mysql_fetch_array($result)){      //array_push($return,array('label'=>$row['productid'],'actor'=>$row['productname']));     //array_push($return,array('value'=>$row['productid'],'label'=>$row['productname']));     //array_push($return,array('actor'=>$row['productname'],'label'=>$row['productid']));     array_push($return,array('productid'=>$row['productid'],'label'=>$row['productname']));  }  header('content-type: application/json'); echo json_encode($return); //var_dump($return);  exit(); // ajax call, don't want carrying on here } else {     header('location:index'); }  ?> 

there's method called _renderitem you'd want use.

here's small demo of in use: http://jsbin.com/cunuxaqe/2/edit


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -