$sql="SHOW TABLES"; while ($row=mysql_fetch_assoc($sql) { $nombre_tabla=$row[0]; $sql_1="SELECT * FROM ".$nombre_tabla; ... resto del código }