I have the below code that I run daily, and which sends notification mail to members if there is an ad in the "ad" table that matches specific criteria saved in "notice" table. Works like the feature on job sites.
My problem is that this code sends every matching ad in separate mail and this way the same member gets multiple emails.
What do I need to modify in this code to make it send one email per member with the ads listed in it like:
Subject of ad 1
Link for ad 1
Subject of ad 2
Link for ad 2
Subject of ad 3
Link for ad 3
.
.
.
etc.
I think maybe nested while or for loops are the solution...
You can see a demo here:
www.mnyknt.hu/alert
I appreciate any help, thanks
$oneday = mysql_query("SELECT * FROM $ads_tbl, $notice_tbl WHERE
$ads_tbl.cat_id = $notice_tbl.cat_id
AND $ads_tbl.biztype = $notice_tbl.biztype
ORDER BY $notice_tbl.email") or error(mysql_error());
while($rowday = mysql_fetch_array($oneday))
{
$ad_id = $rowday['ad_id'];
$subject = $rowday['subject'];
$descript = $rowday['descript'];
$cat_id = $rowday['cat_id'];
$territory = $rowday['territory'];
// email headers
$from = "$ADMIN_EMAIL";
$to = $rowday['email'];
$mailsubject = "New ad listing from $ADVT_NAME";
// the content of the email just for testing
echo $subject."<br>";
echo $ADVT_URL."/ads/view.php?id=".$ad_id."<br>";
echo $to."<br><br>";
// disabled for testing
//sentMail($from, $to, $mailsubject, $body);
}