Hi,
I'd like to create a mail alert, notification script which sends email
to members in the mysql db if there is a new ad posted in the db,
filtered by the criterias each member set. This is in PHP and mySQL.
Similar to what latest php forums use. I have an existing solution but
it doesn't work the way I want.
I have an "ads" table and the an "alert" table.
In the ads table members post their ads with usual fields like:
ad_id, member_id, category, subject, description, city, biztype, etc...
In the alert table they can post their search criterias and their
email address that will be saved.
fields: alert_id, member_id, category, city, biztype, email
(Members can subscribe to multiple categories, thus each member can
have multiple rows in the table. However, only categories will
differ.)
Now when I run the script I want it to "scan through" the two tables
compare them and send email only to those members that have criterias
matching those fields in the "ads" table.
Important thing that I'd like to have it send only one email per
member. In the body of the email there would be the "search result",
the list of matching ads for that member like this:
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.
Please give me a suggestion or solution. Maybe I could use nested
while loops, but I'm not sure how.
I want to run the script daily, so it would select the ads that were
posted in the last 24 hours.
Thank you |