se ho capito bene e le tabelle sono tre
definisciti le variabili e poi le invii io ho fatto così (nb. la connessione la puoi cambiare secondo le tue esigenze)
<?php require_once('Connections/testmp.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_testmp, $testmp);
$query_Recordset1 = "SELECT *, DATE_FORMAT(gg, '%d-%m-%Y') as data_scadenza, to_days(gg) - to_days(curdate()) as quanto_manca FROM asc WHERE CURDATE() = gg - INTERVAL 5 DAY";
$Recordset1 = mysql_query($query_Recordset1, $testmp) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
//if ($totalRows_Recordset1 > 0);
//{
$marca = $row_Recordset1['marca'];
$matr = $row_Recordset1['matricola'];
$palazzo = $row_Recordset1['palazzo'];
$indirizzo = $row_Recordset1['indirizzo'];
$gg = $row_Recordset1['gg'];
$da = "webmaster@tuosito.it";
$danome = "chi invia";
$address = $row_Recordset1['mailente'];
$address1 = $row_Recordset1['mailrno'];
$address2 = $row_Recordset1['mailditta'];
$oggetto = "tuo oggetto";
$bodytxt = "testo se non leggi html - Impianto Marca $marca - Matr. $matr sito in $palazzo. Data scadenza revisione $gg";
$body = "<table width=\"90%\" cellspacing=\"3\" cellpadding=\"3\">
<tr>
<td width=\"38%\"><img src=\"mio.jpg\" alt=\"\" width=\"200\" height=\"119\" /></td>
</tr>
<tr>
<td><p class=\"style1\"></p>
<p class=\"style1\">Verifica biennale impianto sollevamento.</p></td>
</tr>
<tr><?php do { ?>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<th scope=\"col\"><div align=\"left\"><span class=\"Stile3\">Impianto Marca $marca Matr. $matr sito in $palazzo - $indirizzo.</span></div></th>
</tr>
<tr>
<td><span class=\"Stile3\">
Data scadenza revisione <span class=\"Stile4\">$gg</span></span></td>
</tr>
<tr>
<td><span class=\"Stile3\">
<a href=\"mailto:$address\">se vuoi linkare a una mail</a> - <a href=\"address1\">se vuoi linkare a una mail</a> - <a href=\"mailto:address2\">se vuoi linkare a una mail.</a> </span></td>
</tr>
<tr>
<td></td>
</tr>
</table><?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</tr>
<tr>
<td class=\"Stile1\"><span class=\"Stile3\"><a href=\avviso.php\">Controlla la lista</a></span></td>
</tr>
</table>";
$type = "image/jpeg";
require_once("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
//$body = $mail->getFile("avviso.php");
//$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP();
// attiva l'invio tramiteSMTP
$mail->Host = "smtp.tuosito.it";
// indirizzo smtp
$mail->From = $da;
$mail->FromName = $danome;
$mail->AddAddress($address);
$mail->AddCC($address1);
$mail->AddCC($address2);
$mail->IsHTML(true);
$mail->Subject = $oggetto;
//$mail->MsgHTML($body);
//$mail->AddEmbeddedImage("mio.jpg");
$mail->Body = $body;
$mail->AltBody = $bodytxt;
//$mail->AddAttachment("test.zip");
if(!$mail->Send())
{
echo "Message could not be sent.
";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
$mail->ClearAddresses(); // elimino i destinatari
$mail->ClearAttachments(); // elimino gli allegati
$mail->SmtpClose(); // chiudo la connessione SMTP
?>
<?php
mysql_free_result($Recordset1);
?>

Rispondi quotando