I have a script that I wrote and it selects the correct information and sends it to the member. I have it triggered on a cron job to look for matches the members has selected. However, I have two problems.
- The query keeps selecting all the records more then once, so the member gets the same matches multiple times in the same email.
Example
member wants Type = Body Building & City = New York
When the member opens the email they get.
Title Work out plan X Location New York
Title Work out plan X Location New York
Title Work out plan X Location New York
Title Build Muscle in 30 days Location New York
Title Build Muscle in 30 days Location New York
- My other issue is how do I code this so it recognizes to send the match criteria once if I set my cron scipt to run every five minuets. Right now it keeps sending the same email every five minuets.
Example - Member goes to their mail client and sees
You have mail from site X Tuesday 11/17 4:55
You have mail from site X Tuesday 11/17 4:50
You have mail from site X Tuesday 11/17 4:45
In a perfect world the script should only send one that matches the data. Right now I have cron to execute once an hour, so it sends out correctly. However, I would like members to get matches within 5 minuets of it hitting the DB.
Here is my code that's causing me the problem.
$rightnow = time();
$start = $rightnow - 3600;
$res2 = $db->sql_query("SELECT DISTINCT p.id, p.title, p.description, p.type, p.location FROM member_picks AS p INNER JOIN member_content AS a ON (p.type = a.type AND p.location = a.city)WHERE p.type LIKE a.type AND p.location LIKE a.city && added_on BETWEEN ".$start." AND ".$rightnow."");
Any help will be greatly appreciated.