I have a page that sends out emails based on whther a client has reached a certain level of enquiries.
I have a table called mailsent which stores the names of the clients, a date and an id autoincrement field.
I have another table called tstats which stores info relevant to the email i want to send.
The mailsent table is updated with the $row[name] variable, that way the next time the page is accessed it will first check to see if they have already been sent an email. If their name is in the mailsent table, then in theory they should not be pulled out of the tstats table and should not be sent a mail. Thing is they are still a being pulled out of tstats when i know full well that the name contained in mailsent is exactly the same as the name contained in tstats, so why doesnt it work🙁
tia for any suggestions
rob
//look for the client name in the mailsent table
$qry=\\"select name from mailsent\\";
$rst= mysql_query ($qry);
$fetch = mysql_fetch_array ($rst);
//get these fields from the db except where name does not equal $fetch[name]
$qry2=\\"select name, lcount, ecount, total, emailadd from tstats WHERE total >= \\'14\\' AND type = \\'3\\' AND name != \\'$fetch[name]\\'\\";
$rst2= mysql_query ($qry2);
$MailFrom = \\'my email address\\';
$Mail_header = \\"Content-type: text/html\\n\\";
$Mail_header .=\\"From: $MailFrom\\n\\";
while($row=mysql_fetch_array($rst2)){
$name = ucfirst($row[\\'name\\']);
$date = date (\\"d.m.y\\");
$Subject=\\'Important Message \\';
$MailTo = $row[\\'emailadd\\'];
$Body=\\"//code for email content\\";
$mailto = mail($MailTo, $Subject, $Body, $Mail_header);
//update the mailsent table with the names of clients just sent emails
$qry4=\\"insert into mailsent values (\\'\\', \\'$row[name]\\' , NOW())\\";
$rst4= MYSQL_QUERY ($qry4);
}//end loop
if($mailto){
@ $num_results = mysql_num_rows($rst2);
echo\\" $num_results mails sent\\";
}
if(!$mailto){
echo\\\"no mail sent\\\";
}