Basically, am creating a mailer system to send a mail to my inactive members to do activities in their account if they have not logged in since 30 days.

My previous login date stores in my database in unixtimestamp hence i coded as below.

select email from myusers where WHERE DATE_ADD(FROM_UNIXTIME(prelogin), INTERVAL 30 DAY) < CURDATE()";

But this code after 30 days it is sending continuos mails almost everyday as i have set cron to run once a day

Can someone help please

Recommended Answers

Hi,

You can try creating another column on your members table, you can name it anything e.g. notified..

Just right after your script send the email, update this column by inserting some indicator e.g true or false

You can then modify your query above to something like this...

 
Jump to Post

All 2 Replies

Hi,

You can try creating another column on your members table, you can name it anything e.g. notified..

Just right after your script send the email, update this column by inserting some indicator e.g true or false

You can then modify your query above to something like this...

select email from myusers WHERE notified = 'false' AND DATE_ADD(FROM_UNIXTIME(prelogin), INTERVAL 30 DAY) < CURDATE()";
## do your update query below
update myusers WHERE .....set notified value to true, for all affected rows above...

If you are adding your php age in cronjob and assuming it will run daily you can use '<=' as shown below query
.

select email from myusers where WHERE DATE_ADD(FROM_UNIXTIME(prelogin), INTERVAL 30 DAY) <= CURDATE()";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.