PHP: Bold lastname in autosuggest too

radiotiger

New Member
\[code\] $queryString = mysql_real_escape_string($_POST['queryString']);list($firstname, $lastname) = array_map('ucfirst', explode(' ', $queryString, 2));$query = mysql_query("SELECT users.firstname, users.lastname, users.id FROM users INNER JOIN users_friends ON users.id=users_friends.uIDWHERE bID=$USER AND type = '$type' AND (users.firstname LIKE '%$queryString%' OR users.lastname LIKE '%$queryString%') LIMIT 10;");while ($result = mysql_fetch_object($query)) {$re_fname='<b>'.$firstname.'</b>'; $re_lname='<b>'.$lastname.'</b>';$final_fname = str_ireplace($firstname, $re_fname, $result->firstname);$final_lname = str_ireplace($lastname, $re_lname, $result->lastname); echo $final_fname. ' '; echo $final_lname.' ';}\[/code\]This is my code for the searching part in my autosuggest dropdown..I want what youve searched get bold text. Example if you type "Meg" then the "Meg" in Megan, is bold. This does it fine without any problems. But the lastname doesn't work. When I type "Fo" or "Fox" or "F",(Megan Fox) it doesn't get bold in the lastname. Why doesn't this work, and how can i fix this? Is it because $lastname is the text after the space, but I even tried "Megan F" or the full "Megan fox" only Megan gets bold, not "Fox".
 
Back
Top