Salve a tutti...
è da un po di giorni che ci giro intorno senza venirne fuori...

ho un database con le seguenti tabelle :

codice:
CREATE TABLE IF NOT EXISTS Clienti (
	`codcliente`	int(5) PRIMARY KEY,
	`indirizzo`	varchar(50) NOT NULL,
	`email`		varchar(50) NOT NULL,
	`città` 	varchar(50),
	`codfiscale`	varchar(16) NOT NULL,
	`nome`		varchar(50) NOT NULL,
	`cognome`	varchar(50) NOT NULL,
	`datanascita`	date,
	`part_iva`	int(50),
	`iban`		varchar(50)
)ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE IF NOT EXISTS `AccessoInternet` (
	codcliente	int(5),
	username	varchar(50) NOT NULL,
	password	varchar(50) NOT NULL,
	tipo		char(1) NOT NULL,
	FOREIGN KEY (codcliente) REFERENCES Clienti(codcliente) ON UPDATE CASCADE
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
è praticamente un sistema di gestione contatti e clienti con altre tabelle ma il problema è su queste due...

io ora vorrei recuperare i dati di tutti i campi ricercando un cliente per cognome con uno script di ricerca...e vorrei che venissero fuori anche i campi della tabello accessointernet..che ha chiave esterna in clienti...tutto normale sembrerebbe...

ho fatto uno script che inserisco direttamente nella pagina...

Codice PHP:
<form action='clienti.php' method='GET'>

<span style="margin-left:5px">[b]Ricerca[/b]</span>
<span style="margin-left:5px"><input type='text' name='cerca'></span>
<span style="margin-left:5px"><input type='submit' value='Cerca'>
</form>
<div id="contenuto_centro">
<?php


include ('config_db.php');
mysql_select_db('progetto'$connessione) or die ('Errore durante la selezione del db');

$cerca $_GET['cerca'];
    if ( 
$cerca == TRUE && $cerca != "" ) {
                if ( 
strlen($cerca) >= ) {
                    
                    
$cerca =  mysql_escape_string(stripslashes($cerca));
                    
                    
$query1 "SELECT codcliente FROM clienti WHERE cognome LIKE '%$cerca%'";
                    
                    
$ris mysql_query($query1) or die (mysql_error());
                    
                    while(
$rigamysql_fetch_row($ris)) {
                        
                    
$codice_ut$riga[0];
        
                    
$query "SELECT * FROM clienti c NATURAL JOIN accessointernet a WHERE c.codcliente='".$codice_ut."'";
                    
                    
$risultato mysql_query($query) or die (mysql_error()); 
                    
                    
$risposta mysql_query($query) or die ("Utilizza termini più specifici!");

                    
$dentro_la_querymysql_fetch_assoc($risposta);
                
                    if ( 
$dentro_la_query == TRUE ) {

                        while(
$rowmysql_fetch_assoc($risultato)) { 
                            
                            
$codice $row['codcliente'];
                            
$nome $row['nome'];
                            
$cognome $row['cognome'];
                            
$contratto $row['contratto'];
                            
$email $row['email'];
                            
$indirizzo $row['indirizzo'];
                            
$citta $row['citta'];
                            
$codicef $row['codfiscale'];
                            
$datan $row ['datanascita'];
                            
$iban $row['iban'];
                            
$piva $row['part_iva'];
                            
$user $row['username'];
                            
$password $row['password'];
                        
                            
// stampiamo i nostri dati
                            
echo "<table border='1'>
                            <tr>
                            <th>Codice</th>
                            <th>Nome</th>
                            <th>Cognome</th>
                            <th>Email</th>
                            <th>Indirizzo</th>
                            <th>Città</th>
                            <th>Codice Fiscale</th>
                            <th>Data di Nascita</th>
                            <th>Iban</th>
                            <th>Partita Iva</th>
                            <th>User</th>
                            <th>Password</th>
                            </tr>"
;
                            
                             echo 
"<tr>";
                             echo 
"<td>" $codice "</td>";
                             echo 
"<td>" $nome "</td>";
                             echo 
"<td>" $cognome "</td>";
                             echo 
"<td>" $email "</td>";
                             echo 
"<td>" $indirizzo "</td>";
                             echo 
"<td>" $citta "</td>";
                             echo 
"<td>" $codicef "</td>";
                             echo 
"<td>" $datan "</td>";
                             echo 
"<td>" $iban "</td>";
                             echo 
"<td>" $piva "</td>"
                             echo 
"<td>" $user "</td>";
                             echo 
"<td>" $password "</td>";  
                             echo 
"</tr>";
                        }
                    }
                    }
                }
    }
                
?>
adesso praticamente con questo script nel form inserisco il cognome da ricercare e mi stampa il tutto....solo che mi funziona con un solo cliente...che ha codcliente=5...con tutti gli altri no e non capisco il perchè...

Potete dirmi dove sbaglio???GRAZIE