I have a search engine for my website. I have installed a feature like Google's "Did you mean xxx?". It returns corrected string. So, is there a way so that I can compare both of those incorrect and correct strings and bold out the corrected words like Google do?
Here is my code:
<?php
function suggestion($word){
$first_word=substr($word,0,1);
$first_word=strtoupper($first_word);
$query="SELECT * FROM words WHERE UPPER(LEFT(name,1))='$first_word'";
$db_words=mysql_query($query);
$flag=true;
while($row_words=mysql_fetch_array($db_words)){
similar_text($row_words['name'],$word,$percent);
if(($percent>50)&&($percent!=100)){
echo '<strong>Did you mean:</strong><br>';
echo $row_words['name'],'<br>';
$flag=false;
}
}
}
?>