The following code is intended to use levenshtein() to compare a user-input word to the values in a column of a MySQL table:
$searched=$_POST['searched'];
$sql = "SELECT * FROM `word_list`;";
$result = mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($result))
$title = $row['word'];
$sound = levenshtein($searched, $title);
if ($sound < 4) {
echo $title;
}
?>
My confusion stems from the mechanics of actually looping in the values of the "word" column of the table as a variable for the second string int he levenshtein function.
Ultimately, I'd like to loop the values from that column into the $title variable, and echo the values that produce a levenshtein distance less than 4, but I cannot seem to return any output.
whileorfordoesn't really matter. Usebreak;if you want to exit the while prematurely.