I have a MySQL query as below;
$query = "SELECT * FROM dictionary WHERE word LIKE '%".$word."%' ORDER BY word LIMIT 10";
This will search for (and display) words in my dictionary db.
the search will return;
Drunken for Drunk, etc, etc..
,
Drunken for Drunke, etc, etc..
and Drunken for Drunken, etc, etc..
But it won't return Drunken
for Drunkin
. I would like to display this word as a suggestion word (like the one we see in google). How can I do this?
below is my complete code for reference;
$db = new pdo("mysql:host=localhost;dbname=dictionary", "root", "password");
$query = "SELECT * FROM dictionary WHERE word LIKE '%".$word."%' ORDER BY word LIMIT 10";
$result = $db->query($query);
$end_result = '';
if ($result) {
while ( $r = $result->fetch(PDO::FETCH_ASSOC) ) {
$end_result .= $r['word'].'<br>';
}
}
echo $end_result;