Hi,
I'm trying to set up a reliable method of sending an email to all the members of our society. It needs to be something which 3 key people can access - jobs manager, events manager and publicity/press manager.
In english what I want to do is:
Part 1:
Extract $number of entries from jobs - working!
Allow the manager to type a small bit of spiel to add to the top of the email and display it in html - working!
Part 2:
Extract email addresses from members where subscription = Yes - working!
Send an email to those addresses - working!
The problem is that I can't quite fathom how to make part 1 link to part 2, so the spiel and all the extracted jobs/events which appear in part 1 get transferred to the email in part 2.
Here's the code I'm toying with - any suggestions gratefully received!
<?php } //end if !submit
if ($_GET['action']=='send') {
// Get the PHP file containing the DbConnector class
require_once('../sypphp/sypcms/DbConnector.php');
$limit = stripslashes($_POST['limit']);
$spiel = stripslashes($_POST['spiel']);
$connector = new DbConnector();
$result = $connector->query("SELECT id, company, jobtitle, jobdesc, contact, UNIX_TIMESTAMP(dateadded) AS dateadded, closingdate, UNIX_TIMESTAMP(closingdate) AS closingdate FROM jobs ORDER BY closingdate DESC LIMIT 0, $limit") or die ("Error in query: $query. " . mysql_error());
$personalnote = $connector->query("SELECT firstname, email FROM mailtest") or die ("Error in query: $query. " . mysql_error());
if (mysql_num_rows($person) > 0)
{
while ($person = mysql_fetch_array($personalnote));
{
if (mysql_num_rows($result) > 0)
{
//iterate through the resultset
//print job descriptions
$text = '<table align="center" width="100%" cellpadding="4"><tr><td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">';
$text.= 'Dear '.$personal['firstname'].'<br>'
$text.= $spiel;
while ($row = mysql_fetch_array($result))
{
$text.= '<p><h5>'.$row['company'].'<br></h5><h6>'.$row['jobtitle'].'</h6><b>Date added: </b>'.date("d M Y", $row['dateadded']).'</p>';
$text.= '<p>'.$row['jobdesc'].'</p>';
$text.= '<p><b>How to apply: </b><br>'.$row['contact'].'</p>';
$text.= '<p><b>Closing Date: </b>'.date("d M Y", $row['closingdate']).'</p><hr>';
$text.= } //end while result
$text.= '</font></td></tr></table>';
$text.= } //end if rows
$text.= } //end elseif
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: SYP website <webmaster@thesyp.org.uk>\r\n";
$mailto = $row['email'];
mail($mailto, "Mailing test", $text, $headers);
}//end while personal
?>