Levenshtein: MySQL + PHP

Posted by user317005 on Stack Overflow See other posts from Stack Overflow or by user317005
Published on 2011-01-12T16:43:41Z Indexed on 2011/01/12 16:53 UTC
Read the original article Hit count: 244

Filed under:
|
|
$word = strtolower($_GET['term']); 

$lev = 0;

$q = mysql_uqery("SELECT `term` FROM `words`"); 
while($r = mysql_fetch_assoc($q)) 
{ 
    $r['term'] = strtolower($r['term']); 

    $lev = levenshtein($word, $r['term']);

    if($lev >= 0 && $lev < 5)
    {
        $word = $r['term'];
    }
}

how can I move all that into just one query? don't want to have to query through all terms and do the filtering in php.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql