像facebook一样自动完成

I have a question about the development of an AutoComplete, like Facebook in a textarea where the user types the first letters of the name of the friend is shown and a certain list of users that match what he typed.

An image to illustrate http://i.stack.imgur.com/4KXOr.jpg

After some research, I found this script: http://www.hawkee.com/snippet/9391/

At the end of the JS (line 265 of the URL above), i implemented a code to bring me the friends list:

$('#strRecado').triggeredAutocomplete({
        hidden: '#hidden_inputbox',
<?
$vetAmigosRecado = Usuario::getAmigos($_SESSION['sesTuupleCodUsuario']);
$count = count($vetAmigosRecado);

if($vetAmigosRecado) {
    echo "source: new Array(";
    for($i=0; $i<$count; $i++) {
        echo "{'value':'".$vetAmigosRecado[$i]['codUsuario']."',";
        if ($vetAmigosRecado[$i]['fileImagem'] != NULL)
            echo "'img':'".URL."photo.php?param=usuarios/".$vetAmigosRecado[$i]['codUsuario']."/fotos/".$vetAmigosRecado[$i]['fileImagem'].",50,50,2'";
        else
            echo "'img':'".URL."photo.php?param=img/foto_perfil.jpg,50,50,2'";
        echo ",'label':'".$vetAmigosRecado[$i]['nomeCompleto'];
        if($i==$count-1)
            echo "'})
";
        else
            echo "'},
";
    } 
   }
?>

It worked perfectly. The return is getting well:

$('#strRecado').triggeredAutocomplete({
hidden: '#hidden_inputbox',
source: new Array({'value':'USER-CODE','img':'AVATAR-URL','label':'USERNAME'})
});

With everything working as I wanted, came the question: how do I "link", so to speak, the user name and inform the database he was quoted?

Thanks!