Hi There,
I hope somebody can help me with this..
Due to some very dodgy coding I am having a problem with a php3 page.
Heres the problem.
I have a page which should send email alerts automatically to the people who have selected 2 filters in their preferences. This works, but due to an oversite by the coders ( not myself ) in the initial design, it is not working as expected.
What I really need to happen is that the email should only be sent if BOTH filters match not just one.
I am not a coder ( by any stretch of the imagination!! ) but do have some idea about how this all works.
Basically its is selecting from TblOpportunity ( the Db table ) and seeing if the project type ( ProjTypeID ) matches and sends an email alerting the person.
Then it is doing the same thing with the Project Region ( TblMemRegions )
Problem being that I only want the alerts to be sent if BOTH filters match.
Any help would be appreciated and stop a poor html coder from shooting himself!!!
Below is the section of code which sends these alert emails.
$strSel="Select * from TblOpportunity where AllianceRefID='$Allrefids[$i]'";
// CD - added an array to store the email addresses of people who have already had an email sent
$SentEmails = array () ;
// Send automated e-mail to members who are interested in the Project Type
$result=mysql_query($strSel);
while($row1=mysql_fetch_array($result))
{
$strcountry="select CountryDesc from TblMCountries where CountryID=$row1[ProjCountry]";
$rescountry=mysql_query($strcountry);
$rowcountry=mysql_fetch_array($rescountry);
$strProj="select MLgName from TblMemProjectTypes where ProjTypeID ='$row1[ProjTypeID]'";
$res1=mysql_query($strProj);
while($row=mysql_fetch_array($res1))
{
$strMember="select * from TblCpMembers where MLgName='$row[MLgName]'";
$res2=mysql_query($strMember);
$memrow = mysql_fetch_array($res2);
$sendto=$memrow[MEmail];
$to=trim($sendto);
$subject=$row1[ProjName];
$body="An opportunity or project matching your chosen filters criteria, has been posted to the Opportunity Database</a><br><br>Project Name: ".$txtProjName."<br><br>Country of Opportunity:".$rowcountry["CountryDesc"]."<br><br><br>".$txaProjDesc;
// CD - add email address to sent emails
$SentEmails [ $sendto ] = true ;
include('./include/email.inc');
}
/// Send automated e-mail to members who are interested in the given Region
$strReg= "select MLgName from TblMemRegions where RegID ='$row1[RegID]'";
$res3=mysql_query($strReg);
while($row2=mysql_fetch_array($res3))
{
$strMember1="select * from TblCpMembers where MLgName='$row2[MLgName]'";
$res4=mysql_query($strMember1);
$memrow = mysql_fetch_array($res4);
$sendto=$memrow[MEmail];
// CD - see if user has not already received the email
if ( $SentEmails [ $sendto ] != true )
{
$to=trim($sendto);
$subject=$row1[ProjName];
$body="An opportunity or project matching your chosen filters criteria, has been posted. Please refer to the Opportunity Database</a><br><br>Project Name: ".$txtProjName."<br><br>Country of Opportunity:".$rowcountry["CountryDesc"]."<br><br><br>".$txaProjDesc;
include('./include/email.inc');
}
}
}
}
echo $strHtml;
Again thanks for any help.
Mark Rendell