I am trying to make a search page whereby I can order results by their similarity to the search query
$search_query = 'this is the users search query';
$sql =$mysqli->query("SELECT column_name
FROM table_name
WHERE column_name LIKE $search_query
**ORDER BY SIMILARITY TO $search_query**");
I have tried using the php similar_text()
function as follows
while($row= $sql->fetch_object()){
$percent = similar_text($search_query,$row->column_name,$percent);
$sql_results =$mysqli->query("SELECT column_name
FROM table_name
ORDER BY $percent");
while($row = $sql_results->fetch_object()){
echo // results
}
}
though I am entirely sure that this is not the best way to do this and after much searching with no solutions I posted here. Any help would be awesome thanks!