$dati = "<html>
<head><title>Richiesta</title>
<style type=\"text/css\">
<!--
A:link { font-family: verdana; font-size: 10px; color: $colore_testo; text-decoration: none; font-weight: bold;}
A:visited { font-family: verdana; font-size: 10px; color: $colore_testo; text-decoration: none; font-weight: bold;}
A:hover { font-family: verdana; font-size: 10px; color: $colore_testo; text-decoration: underline; font-weight: bold;}
-->
</style>
</head>
<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
<table border='0' width='760' cellpadding='0' cellspacing='0' align='center'>
<tr><td>
<table border='0' width='760' cellpadding='0' cellspacing='0'>
<tr><td>[img][/img]</td></tr>
<tr><td><font face='Verdana' color='$colore_testo' size='2'>
Cognome: $cognome
Nome: $nome
Indirizzo: $via - $cap $citta $prov $nazione
Telefono: $telefono
Fax: $fax
Email: $mail
Info: $info
<hr>
Ente: $ente
".
$esito1 = pg_Exec($conn,"SELECT * FROM tab where idc = '$idc' AND idr = '$idr' AND idp = '$idp';");
if (!$esito1) { echo "Errore filtro.\n"; exit; }
$num1 = pg_NumRows($esito1);
$a = 0;
while ($a < $num1) {
$idc=pg_Result($esito1, $a, "idc");
$idr=pg_Result($esito1, $a, "idr");
$idp=pg_Result($esito1, $a, "idp");
$ente=pg_Result($esito1, $a, "ente");
$scala=pg_Result($esito1, $a, "scala");
$anno=pg_Result($esito1, $a, "anno");
$tipoc=pg_Result($esito1, $a, "tipoc");
$note=pg_Result($esito1, $a, "note");
$esito2 = pg_Exec($conn,"SELECT * FROM scala");
$num2 = pg_NumRows($esito2);
$f = 0;
$sca = split ('[.]', $scala);
while ($f < $num2){
if ($sca[$f] <> '') {
$esito11 = pg_Exec($conn,"SELECT * FROM tab where ids = '$sca[$f]'");
$sca1=pg_Result($esito11, 0, "scala");
."<font face='Verdana' color='$colore_testo' size='1'>Scala: $sca1</font>".
}
$f++;
}
$a++;
}
."Anno: $anno
Tipo: $tipoc
Note: $note</font></td>
</td></tr>
</table>
</td></tr>
<tr><td>
</table>
</body>
</html>";
$subject ="Richiesta";
$headers1 .= "From: $sito\n"; ## mittente
$headers1 .= "X-Sender: <$mail>\n";
$headers1 .= "X-Mailer: PHP\n"; // mailer
$headers1 .= "Return-Path: <$mail>\n";
$headers1 .= "Content-Type: text/html; charset=iso-8859-1\n";
$headers1 .= "MIME-Version: 1.0\r\n";
mail($mail, $subject, $dati, $headers1) or print "Impossibile inviare il messaggio";