samedi 28 février 2015

how to add different images to PHP Live Search result?

my PHP live search code working without any issues.i have added a thumbnail to drop down search result.same image(site logo) to every search result. but now i need to add different images to drop down search result. eg: facebook live search with different profile pictures.


what i want : Bob's profile picture and details when i type "Bob" in search box.Mark's profile picture and details to dropdown live search result,when i type "Mark" in search box.


I'm only posting my search.php file here.i think it's enough for my question.this code adding one thumbnail (image.jpg) to all dropdown live search results. How to add different thumbnails to each results?



<?php
include('db.php');
if($_POST)
{
$q = mysql_real_escape_string($_POST['search']);
$strSQL_Result = mysql_query("select id,name,email from live_search where name like '%$q%' or email like '%$q%' order by id LIMIT 5");
while($row=mysql_fetch_array($strSQL_Result))
{
$username = $row['name'];
$email = $row['email'];
$b_username = '<strong>'.$q.'</strong>';
$b_email = '<strong>'.$q.'</strong>';
$final_username = str_ireplace($q, $b_username, $username);
$final_email = str_ireplace($q, $b_email, $email);
?>
<div class="show" align="left">
<img src="image.jpg" style="style here"><?php echo $final_username; ?></span>&nbsp;<br/><?php echo $final_email; ?><br/>
</div>
<?php
}
}
?>

Aucun commentaire:

Enregistrer un commentaire