Ciao ragazzi, ho creato questo codice

Codice PHP:
$query mysql_query("
SELECT * 
FROM preventivi_clienti
INNER JOIN preventivi_prodotti
ON preventivi_clienti.preventivi_clienti_ses = preventivi_prodotti.ses
INNER JOIN shop_prodotti
ON shop_prodotti.id =  preventivi_prodotti.id_prodotto
"
);

while(
$result mysql_fetch_array($query)) 

$id_db =  $result['preventivi_clienti_id'];
$id_dbmb_convert_encoding(htmlspecialchars($id_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$nome_db $result['preventivi_clienti_nome'];
$nome_db mb_convert_encoding(htmlspecialchars($nome_db ENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$cognome_db =  $result['preventivi_clienti_cognome'];
$cognome_dbmb_convert_encoding(htmlspecialchars($cognome_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$indirizzo_db $result['preventivi_clienti_indirizzo'];
$indirizzo_db mb_convert_encoding(htmlspecialchars($indirizzo_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$cap_db $result['preventivi_clienti_cap'];
$cap_db mb_convert_encoding(htmlspecialchars($cap_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$citta_db $result['preventivi_clienti_citta'];
$citta_db mb_convert_encoding(htmlspecialchars($citta_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$stato_db $result['preventivi_clienti_stato'];
$stato_db mb_convert_encoding(htmlspecialchars($stato_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$telefono_db $result['preventivi_clienti_telefono'];
$telefono_db mb_convert_encoding(htmlspecialchars($telefono_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$email_db $result['preventivi_clienti_email'];
$email_db mb_convert_encoding(htmlspecialchars($email_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$data_db $result['preventivi_clienti_data'];
$data_db mb_convert_encoding(htmlspecialchars($data_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$note_db $result['preventivi_clienti_note'];
$note_db mb_convert_encoding(htmlspecialchars($note_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$id_prodotto_db $result['id_prodotto'];
$id_prodotto_db mb_convert_encoding(htmlspecialchars($id_prodotto_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$qnt_prod_db $result['qnt'];
$qnt_prod_db mb_convert_encoding(htmlspecialchars($qnt_prod_dbENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');


$nome_prodotto $result['nome'];
$nome_prodotto mb_convert_encoding(htmlspecialchars($nome_prodottoENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$art_prodotto $result['articolo'];
$art_prodottomb_convert_encoding(htmlspecialchars($art_prodottoENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

$unita_prodotto $result['unita'];
$unita_prodottomb_convert_encoding(htmlspecialchars($unita_prodottoENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');


$prezzo_prodotto $result['prezzo'];
$prezzo_prodottomb_convert_encoding(htmlspecialchars($prezzo_prodottoENT_NOQUOTES'Windows-1252'), 'UTF-8''Windows-1252');

echo 
"
    <Document>
      <DocumentType>C</DocumentType>
      <CustomerCode>
$id_db</CustomerCode>
      <CustomerName>
$nome_db $cognome_db</CustomerName>
      <CustomerAddress>
$indirizzo_db</CustomerAddress>
      <CustomerPostcode>
$cap_db</CustomerPostcode>
      <CustomerCity>
$citta_db </CustomerCity>
      <CustomerProvince></CustomerProvince>
      <CustomerCountry>
$stato_db </CustomerCountry>
      <CustomerVatCode></CustomerVatCode>
      <CustomerTel>
$telefono_db</CustomerTel>
      <CustomerEmail>
$email_db</CustomerEmail>
      <Date>
$data_db</Date>
      <Number></Number>
      <Total></Total>
       <InternalComment>Nessun Acconto</InternalComment>
      <CustomField1>
$note_db</CustomField1>
      <Row>
        <Code>
$art_prodotto</Code>
        <Description>
$nome_prodotto</Description>
        <Qty>
$qnt_prod_db</Qty>
        <Um>pz</Um>
        <Price>
$prezzo_prodotto</Price>
        <Discounts>5%</Discounts>
        <VatCode>20</VatCode>
      </Row>

    </Document>"
;

Il codice funziona, solo che non fà quello che voglio io, adesso vi spiego.

Il codice mi da questo risultato

cliente1
prodotto1

cliente1
prodotto2

cliente1
prodotto3

Io invece vorrei una cosa del genere

cliente1
prodotto1
prodotto2
prodotto3

Il problema penso sia il while..

Mi sapete dare un consiglio su come fare?

Ciau