Page 1 of 1

Match the News title with user, then sends user the email

Posted: Fri Apr 24, 2009 12:31 am
by aaview
Hello everyone,

I am a newbie here. Hope to learn from all of you.
I have only very basic php skills, like store, delete items in database.

My website is sort of a newspaper.. which is constantly updated with the latest news.
I stored all these news in a table called "LatestNews"
It has 2 fields: "Title" and "Body"

I also have users that subscribe. My users can also store up to 5 of their favorite "keywords" into the MySql.
I stored all these data in table called "Users"
It has a 3 fields like "Name", "Email" and "favoritewords"

Scenario
Lets say, the user enters in "BMW" into his favourite words.
then lets say..... i posted a news, with the title BMW cars for sale.
It will automatically sends my user an alert email about the latest news I posted.

How can I do that ?
are there any scripts out there ?

Thanks so much

Re: Match the News title with user, then sends user the email

Posted: Fri Apr 24, 2009 12:13 pm
by aaview
anyone has any idea how to go about ?

Re: Match the News title with user, then sends user the email

Posted: Fri Apr 24, 2009 12:28 pm
by Cryophallion
Easiest thing would be to create yourself a CMS (or use one already existing). Upon insert, a script would be called to send it to users who have that item.

I would use a join table for this, where each topic type has an id, and each user has one, and both numbers are stored in a table by itself.

Then, upon insert:
<pseudocode>
SELECT user.email, user.name FROM user, usercats where user.userid = usercats.userid and usercats.catid = {$id};
</pseudocode>
Then, create the mail body, header, etc using the inserted info, and use mail() to send it.

Re: Match the News title with user, then sends user the email

Posted: Fri Apr 24, 2009 9:29 pm
by aaview
thanks for the advice Cryophallion.
very good inputs.

hmmm... am I the first to implement such a thing ?
aren't there any available scripts out there ?