i try to make a "live-search".
What I want
Searchstring 1: "%ete%"
Searchstring 2: "%er%"
| City | Land | Artist |
-----------------------------
| Köln | Germany | Peter |
| Bonn | Germany | Bernd |
| Berlin | Germany | Karl |
-----------------------------
Result 1: Peter
Result 2: Germany AND Berlin AND Peter AND BERND
i have a jquery keyup event, a ajax and this php/mysql script:
$query=$_POST['value'];
$result='<ul class="db_s_answer">';
$abfrage = mysql_query("SELECT * FROM imgdb WHERE artist LIKE '%".$query."%' OR ort LIKE '%".$query."%' LIMIT 5");
while ($row = mysql_fetch_object($abfrage)) {
$ergebnis=preg_replace("/".$query."/i","<b>$0</b>",HERE THE MOST FITTING VARIABLE,-1);
$result.='<li><div><p>'.$ergebnis.'</p></div></li>';
}
$result.='</ul>';