http://www.devpro.it/php4_id_1.html
ti fai una stringa da 5 a 8 o quanti ne vuoi, controlli che non sia gia' presente nella tabella dedicata che contiene
id id_utente stringa_5_8
se non e' gia' stata selezionata * la assegni all' utente e la aggiungi alla tabella in questione
* ESEMPIO
$q = query( "select stringa_5_8 from tabella" );
$usate = Array();
while( $r = &fetch_num( $q ) ) {
array_push( $usate, $r[0] );
}
$trovato = false;
while( $trovato == false ) {
if( in_Array( ( $stringa_5_8 = randomString(8,1) ), $usate ) == false ) {
$trovato = true;
}
}
$q = query( "insert into tabella values( "", {$id_utente}, {$stringa_5_8} )" );