prova cosi'... ma che te ne fai del numero di tabelle???
codice:$stringa= "show table status LIKE 't%'" ; $tabelle = mysql_query("$stringa") or die(mysql_error()); while ($rec_tabelle = mysql_fetch_row($tabelle)) { $lista[] = $rec_tabelle['0']; } foreach($lista as $tab) { $query= mysql_query("SELECT * FROM $tab where cognome = '$cognome'"); while ($row = mysql_fetch_assoc($query)) { echo "COGNOME: " . $row['cognome'] . " "; } }