Hello,
My code below queries a database & sends the results via email. The code is working fine.
I'm now trying to place an "unsubscribe" message at the bottom of the email. No matter what I try, the "unsubscribe" message appears at top of the email. How do I make the message appear at the bottom of the email?
Thanks.
<?php
//connection to mysql database
$mktime = date('Y-m-d');
$query1=("SELECT * FROM developer_log WHERE '$mktime' < expiry ORDER BY id ASC");
$result1=mysql_query($query1);
$num1=mysql_num_rows($result1);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: someone@yourwebsite.com' . "\r\n" .
'Reply-To: someone@yourwebsite.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "Latest Approved Residential Developments";
$message_tmp = "<h3>List of Latest Approved Residential Developments</h3>";
$message_tmp .= "<table bgcolor='black' cellspacing='1' width='100%'><tr bgcolor='white' align='center'>";
$message_tmp .= "<td><b>Year Approved</b></td>";
$message_tmp .= "<td><b>Name of Developer</b></td>";
$message_tmp .= "<td><b>Name of Project</b></td>";
$message_tmp .= "<td><b>Type of Property</b></td>";
$message_tmp .= "<td><b>Levels</b></td>";
$message_tmp .= "<td><b>Number of Units</b></td>";
$message_tmp .= "</tr>";
$message_tmp .= "[new_rows]";
while ($row1 = mysql_fetch_array($result1))
{
$id = $row1["id"];
$company = $row1["company"];
$project = $row1["project"];
$property = $row1["property"];
$email = $row1["email"];
$cc_email = $row1["cc_email"];
$query2= "SELECT * FROM developer WHERE date_updated < '$mktime' AND name LIKE '%{$row1['company']}%' OR development LIKE '%{$row1['project']}%' OR type LIKE '%{$row1['property']}%'";
$result2=mysql_query($query2);
$num2=mysql_num_rows($result2);
$new_rows = "";
while ($row2 = mysql_fetch_array($result2))
{
$new_rows .= "<tr bgcolor='white' align='center'>";
$new_rows .= "<td>".$row2["year"]."</td>";
$new_rows .= "<td>".$row2["name"]."</td>";
$new_rows .= "<td>".$row2["development"]."</td>";
$new_rows .= "<td>".$row2["type"]."</td>";
$new_rows .= "<td>".$row2["levels"]."</td>";
$new_rows .= "<td>".$row2["quantity"]."</td>";
$new_rows .= "</tr>";
}
if (!empty($new_rows))
{
$message = str_replace("[new_rows]",$new_rows,$message_tmp);
mail("$email,$cc_email", $subject, $message, $headers, "-fsomeone@yourwebsite.com");
}
}
?>