PDO::ERRMODE_EXCEPTION )); } catch (Exception $e) { die("Error : ".$e->getMessage()); } $req = $db->prepare('SELECT taxon_species FROM `taxa`'); $req->execute(); $result = $req->fetchAll(); $species = array(); foreach ($result as $row) { $species[] = $row['taxon_species']; } $q = $_REQUEST['q']; $hint = array(); // print_r($species); if ($q !== "") { $q = strtolower($q); $len = strlen($q); foreach($species as $sp) { if (stristr($q, substr($sp, 0, $len))) { $hint[] = $sp; } } } // Output "no suggestion" if no hint was found or output correct values ?>